mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Write to a marker file to determine when the slow server component finishes rendering instead of trying to sleep for some fixed amount of time.
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { Suspense } from 'react'
|
|
import { connection } from 'next/server'
|
|
import { HydrationIndicator } from '../../hydration-indicator'
|
|
import waitForMarkerFile from '../../../waitForMarkerFile'
|
|
import type { Metadata } from 'next'
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
await connection()
|
|
return {
|
|
title: 'Resume test',
|
|
}
|
|
}
|
|
|
|
export default function Page() {
|
|
return (
|
|
<main id="shell">
|
|
<h1>This is a page with static shell + streaming metadata</h1>
|
|
<div>
|
|
<p>Static shell</p>
|
|
<HydrationIndicator id="shell-hydrated" />
|
|
<hr />
|
|
<Suspense fallback={<div id="dynamic-fallback">Loading...</div>}>
|
|
<SlowServerComponent />
|
|
</Suspense>
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
async function SlowServerComponent() {
|
|
await connection()
|
|
await waitForMarkerFile()
|
|
const randomValue = Math.floor(Math.random() * 1000)
|
|
return (
|
|
<div id="dynamic">
|
|
<div>{`Random value: ${randomValue}`}</div>
|
|
<HydrationIndicator id="dynamic-hydrated" />
|
|
</div>
|
|
)
|
|
}
|