GifproGifpro

待たせない!SuspenseでストリーミングSSR

代码预览

P

提示词

Generate a page that demonstrates React Suspense with streaming server-side rendering. Include a code snippet showing how to wrap a slow data-fetching component with Suspense and a fallback, and explain how it enables progressive HTML streaming.

ReactのSuspense + ストリーミングSSRを使うと、サーバーがHTMLをプログレッシブに送信できます。データ待ちのコンポーネントはフォールバック(スピナーなど)を即座に送り、準備ができた時点で実際の内容をストリーミング。初回バイト到達時間が短縮され、体感パフォーマンスが向上します。

例では、遅いコンポーネントを<Suspense fallback={<Loading />}>でラップ。サーバーはフォールバックを即座にレンダリングし、残りをストリーミングで送ります。

这个提示对您有帮助吗?

评论

评论将在审核后显示

首页ヘルプ