mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
prefetching is now controlled with the prefetch export and this option is inert on the instant export. this removes the prefetch option as a valid property on the instant config type. also updates the ts plugin for this export and adds the definition for the previously landed prefetch export
34 lines
780 B
TypeScript
34 lines
780 B
TypeScript
import { Suspense } from 'react'
|
|
import { cacheLife } from 'next/cache'
|
|
import { cookies } from 'next/headers'
|
|
|
|
export const unstable_instant = true
|
|
export const unstable_prefetch = 'force-runtime'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<Suspense fallback="Loading...">
|
|
<RuntimePrefetchable />
|
|
</Suspense>
|
|
)
|
|
}
|
|
|
|
async function RuntimePrefetchable() {
|
|
// Prevent this content from appearing in a regular prerender,
|
|
// But allow it to be included in a runtime prefetch.
|
|
await cookies()
|
|
|
|
return (
|
|
<Suspense fallback="Loading...">
|
|
<Content />
|
|
</Suspense>
|
|
)
|
|
}
|
|
|
|
async function Content() {
|
|
'use cache'
|
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
cacheLife({ stale: 4 * 60 })
|
|
return 'Content with stale time of 4 minutes'
|
|
}
|