Next.js App Router Best Practices

Chapter 1 · Practice 2 of 5

Await params, searchParams, cookies and headers

From Server and Client Components

Why it matters

Old tutorials read request data synchronously, and that code now breaks. Since Next.js 15, request APIs are asynchronous, and Next.js 16 removed the temporary synchronous access, so reading params.slug directly fails.

APIWhereHow to read it
params, searchParamspages, layouts, generateMetadataconst { slug } = await params
cookies(), headers()from next/headersconst store = await cookies()

Use the generated PageProps<'/route'> and LayoutProps<'/route'> helpers to type them.

Avoid

  • Reading params.id without awaiting
  • Awaiting params in a layout when only a nested component needs it