next.js/test/e2e/app-dir/instant-validation/app/suspense-in-root/head/valid-dynamic-metadata-in-runtime/page.tsx
page.tsx39 lines896 B
import { Metadata } from 'next'
import { cookies } from 'next/headers'
import { connection } from 'next/server'
import { Suspense } from 'react'

export const unstable_instant = true
export const unstable_prefetch = 'force-runtime'

export async function generateMetadata(): Promise<Metadata> {
  await connection()
  return {
    title: 'Blocked by connection',
  }
}

export default async function Page() {
  await cookies()
  return (
    <main>
      <p>
        This page has a generateMetadata that accesses connection. It's
        runtime-prefetchable, but metadata doesn't block, so it's fine.
      </p>
      <p>
        We also access connection in the page itself, because a runtime page
        with dynamic metadata is not allowed.
      </p>
      <Suspense>
        <Dynamic />
      </Suspense>
    </main>
  )
}

async function Dynamic() {
  await connection()
  return null
}
Quest for Codev2.0.0
/
SIGN IN