Next.js › Loading UI & Streaming with Suspense
How would you design loading states for a complex page with several independently loading sections to avoid a jarring, jumpy user experience?
AdvancedAnswer
You design skeleton loading placeholders that closely match the actual size and shape of the content that will eventually appear, use consistent Suspense boundaries so sections load in a predictable order, and avoid excessive layout shift by reserving the correct amount of space for each section before its real content arrives.
function CardSkeleton() {
return <div className="h-32 w-full animate-pulse bg-gray-200 rounded" />;
}
<Suspense fallback={<CardSkeleton />}>
<ProductCard />
</Suspense>Real-world example A product listing page uses skeleton cards that match the exact size of the real product cards, so the page layout does not jump around awkwardly as real content streams in and replaces the placeholders.