import { cacheLife } from 'next/cache' import { cookies, headers } from 'next/headers' import { connection } from 'next/server' import { setTimeout } from 'timers/promises' import { Suspense } from 'react' export const unstable_instant = { prefetch: 'runtime', samples: [ { cookies: [{ name: 'testCookie', value: 'testValue' }], headers: [['x-test-header', 'test']], searchParams: {}, }, ], } export default async function Page({ searchParams, }: { searchParams: Promise<{ q?: string }> }) { return (
Loading search params...

}>
Loading cookies...

}>
Loading headers...

}>
Loading connection...

}>
) } async function CachedContent() { 'use cache' cacheLife({ stale: 120 }) return

Cached content ({new Date().toISOString()})

} async function SearchParamsContent({ searchParams, }: { searchParams: Promise<{ q?: string }> }) { 'use cache: private' cacheLife({ stale: 30 }) const { q } = await searchParams await setTimeout(300) return (

Search params: {q ?? 'none'} ({new Date().toISOString()})

) } async function CookiesContent() { 'use cache: private' cacheLife({ stale: 30 }) const cookieStore = await cookies() const value = cookieStore.get('testCookie')?.value ?? 'none' await setTimeout(300) return (

Cookie: {value} ({new Date().toISOString()})

) } async function HeadersContent() { 'use cache: private' cacheLife({ stale: 30 }) const headerStore = await headers() const value = headerStore.get('x-test-header') ?? 'none' await setTimeout(300) return (

Header: {value} ({new Date().toISOString()})

) } async function ConnectionContent() { await connection() await setTimeout(600) return

Dynamic content ({new Date().toISOString()})

}