Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Next.js 15: Route used params, params should be awaited

In Next.js 15 params, searchParams, cookies and headers are Promises. Await them in pages, layouts, metadata and route handlers, then fix the types.

~5 min readNext.js
#nextjs#app-router#server-components#migration
Bold white headline reading AWAIT PARAMS with a Next.js route crate holding a cyan promise block behind an amber gate.

Introduction & Quick Summary

After upgrading to Next.js 15, a dynamic route that worked for months throws on the first request:

code
Error: Route "/blog/[slug]" used `params.slug`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Quick answer: params, searchParams, cookies(), headers() and draftMode() are Promises in Next.js 15. Await them, and type them as Promises.

tsx
// app/blog/[slug]/page.tsx export default async function Page({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const post = await getPost(slug); return <article>{post.title}</article>; }

Two separate failures are reported with almost the same words, and they need different fixes. The runtime error above comes from reading a property on the Promise object (params.slug is undefined). The build error comes from the type: Type '{ params: { slug: string } }' does not satisfy the constraint 'PageProps' because the framework now declares params as Promise<{ slug: string }>. Fixing the type without the await leaves a page that compiles and renders undefined.

The change exists for partial prerendering and streaming: the framework can start rendering before the request's dynamic values are known. That is also why the value arrives as a Promise rather than a plain object — every consumer must opt in to waiting.

Core Mechanics, Signatures & Reproducible Setup

Reproduce with the official codemod disabled, so the failure is visible:

bash
npx create-next-app@latest next15-async --ts --app --no-tailwind --no-eslint cd next15-async mkdir -p app/blog/\[slug\] cat > app/blog/\[slug\]/page.tsx <<'TSX' export default function Page({ params }: { params: { slug: string } }) { return <h1>{params.slug}</h1>; // runtime error in Next 15 } TSX npm run dev
APINext.js 14Next.js 15Where it is used
paramsplain objectPromise<object>page, layout, route handler, generateMetadata
searchParamsplain objectPromise<object>page only
cookies()sync getterreturns a Promiseserver code, actions, route handlers
headers()sync getterreturns a Promiseserver code, actions, route handlers
draftMode()syncreturns a Promisepreview routes
generateStaticParamsarrayarray, unchangedprebuild only

The props type is generated from the route. Instead of hand-writing it, import the helper the framework ships with typed routes:

tsx
export default async function Page(props: PageProps<"/blog/[slug]">) { const { slug } = await props.params; return <h1>{slug}</h1>; }

For client components the value cannot be awaited, because they do not run on the server. Next.js 15 supports unwrapping a Promise with React.use, and useParams remains the simplest read:

tsx
"use client"; import { use } from "react"; export function SlugLabel({ params }: { params: Promise<{ slug: string }> }) { const { slug } = use(params); // unwraps on the client return <span>{slug}</span>; }

Key Comparison Table

LocationSignatureCorrect readFailure if wrong
Page (server){ params: Promise<{ slug: string }> }const { slug } = await paramsruntime sync-API error
Layoutsame as pageawait paramslayout renders undefined route
generateMetadata(props: { params: Promise<...> })const { slug } = await props.paramswrong title, cached at build
Route handler(req, ctx: { params: Promise<...> })const { id } = await ctx.params500 on every call
Client componentprop typed as Promiseuse(params) or useParams()hook rules violated if awaited
generateStaticParamsno params argumentreturn array of segmentsnot a place for await params

What changed for the same code in one place:

CodeNext.js 14Next.js 15Note
params.slugworksundefined plus errorreadable, never typed as a Promise
await paramsworks, harmlessworksawait on a plain object is legal
cookies().get("id")workserrormust be (await cookies()).get("id")
headers().get("host")workserrorsame pattern
searchParams.pagestringundefinedawait first, then read
dynamic = "force-static"params availableparams are emptyintentional under PPR

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. generateMetadata runs before the page

Metadata is generated by a separate call, so awaiting params in the page does not help here:

tsx
export async function generateMetadata({ params, }: { params: Promise<{ slug: string }>; }): Promise<Metadata> { const { slug } = await params; const post = await getPost(slug); return { title: post.title, description: post.excerpt }; }

A missed await here is quiet: the page renders, but the document title becomes undefined and the value is cached with the route. Check the built HTML, not just the browser tab after client navigation.

2. Route handlers and the second argument

ts
// app/api/orders/[id]/route.ts export async function GET( _req: Request, ctx: { params: Promise<{ id: string }> }, ) { const { id } = await ctx.params; return Response.json({ id }); }

In Next.js 14 the same handler typed { params: { id: string } }. A handler that still does ctx.params.id answers 500 only on requests that reach a dynamic segment, so a health check on a static route stays green and the breakage hides until traffic arrives. Reproduce the actual request with the cURL command builder, then inspect the returned JSON with the JSON formatter.

3. Await once, then pass values down

Awaiting the same Promise repeatedly is safe, but reading it inside JSX leads to await in places that must stay synchronous:

tsx
export default async function Page({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; // one read at the top const post = await getPost(slug); return ( <div> <PostHeader post={post} /> <Comments slug={slug} /> </div> ); }

Passing slug rather than the Promise keeps child components ordinary and testable. Components that need several values should accept resolved props, not the route object.

4. useSearchParams inside a client component

searchParams is server-only; client components read the query through the hook, which requires a Suspense boundary during prerender:

tsx
"use client"; import { useSearchParams } from "next/navigation"; function Filters() { const sp = useSearchParams(); return <p>page {sp.get("page") ?? "1"}</p>; } export default function Page() { return ( <Suspense fallback={<p>Loading…</p>}> <Filters /> </Suspense> ); }

This is where the two errors meet: a missing Suspense reports a CSR bailout, and a missing await reports the sync-API error. When a query string misbehaves, decode it with the URL encoder to see whether the value is double-encoded before blaming the framework.

5. Layouts, nested segments and parallel routes

A layout receives only the segments above it. params in app/blog/[slug]/layout.tsx is a Promise holding { slug }, not the whole path. For catch-all routes, type the segments as arrays:

tsx
export default async function DocsLayout({ params, }: { params: Promise<{ path: string[] }>; }) { const { path } = await params; return <nav aria-label={path?.join("/")}>{/* … */}</nav>; }

Optional catch-all segments return string[] | undefined, so guard before .join. In parallel routes, each slot resolves its own params; awaiting the parent's params in a slot that does not receive them gives a type error at build.

6. Static rendering, force-static and tests

With export const dynamic = "force-static", dynamic APIs return empty values by design: params resolves to {} and searchParams to an empty object. A page that needs the slug for content must not force static mode. In Playwright and other E2E tests, the same rule applies to mocks: a test helper that builds { params: { slug } } must now build { params: Promise.resolve({ slug }) }, or every test fails with the same sync-API message regardless of the code under test.

Common Compilation/Runtime Mistakes & Version Gotchas

Adding async without changing the type. async function Page({ params }: { params: { slug: string } }) compiles the body but fails the generated PageProps check. The type is what breaks the build, so change both together.

Awaiting in a client component. await is a syntax error outside an async function, and client components cannot be async. Use use(params) from React 19 or useParams().

Reading searchParams on a static route. Touching searchParams opts the page into dynamic rendering; with force-static the value is empty. If a page must stay static, read query state on the client with useSearchParams.

Forgetting cookies() and headers() in the same commit. They moved at the same time as params. A codebase that fixed pages but not actions fails later in a server action, where the stack trace points at the action rather than the upgrade.

Assuming await params costs a request. The Promise is already resolved; awaiting it adds a microtask, not I/O. Memoize data fetches instead of the params object.

Version notes. Next.js 15 makes the request APIs async and ships next-async-request-api in @next/codemod. Next.js 15.1 restored some legacy sync access behind experimental.staleTimes unrelated flags, so a project on a canary build may warn instead of throw. Next.js 16 removes the compatibility layer entirely. PageProps and RouteContext global helpers exist from 15.5 with typed routes enabled.

Reference material: page.js file convention and the Next.js 15 upgrade guide.

Official references

primary documentation

The Next.js documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Next.js work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Next.js guides

More in Next.js

All Next.js guides

The guides filed next to this one in Next.js, in library order.