next.js/test/e2e/app-dir/use-cache/app/(partially-static)/generate-viewport-resume/page.tsx
page.tsx32 lines718 B
import { Viewport } from 'next'
import { connection } from 'next/server'
import { Suspense } from 'react'

export async function generateViewport({
  searchParams,
}: {
  searchParams: Promise<Record<string, string | string[] | undefined>>
}): Promise<Viewport> {
  'use cache'

  // Explicitly not reading search params here. The search params should be
  // omitted from the cache key, so that we ensure a cache hit when resuming the
  // partially prerendered page.

  return { initialScale: Math.random() }
}

export default function Page() {
  return (
    <Suspense fallback={<p>Loading...</p>}>
      <Dynamic />
    </Suspense>
  )
}

async function Dynamic() {
  await connection()

  return <p>Dynamic</p>
}
Quest for Codev2.0.0
/
SIGN IN