Skip to content
Loadout

Fix

Next.js 16 params and cookies are async

Answer

In Next.js 16 params and searchParams are Promises. Always await them. cookies(), headers(), and draftMode() from next/headers are async. Await them. Synchronous access typechecks in places and crashes at runtime.

  • Next.js 16.4.5
  • React 19.3
  • @supabase/ssr 0.12.7
  • @supabase/supabase-js current, installed alongside @supabase/ssr

Last verified 2026-11-04

Agents still treat params and searchParams as plain objects, and they still call cookies(), headers(), and draftMode() without await. Synchronous access typechecks in places and crashes at runtime. The Next.js + Supabase pack is written to stop that paste. It pins Next.js 16.4.5, React 19.3, @supabase/ssr 0.12.7, and @supabase/supabase-js (current, installed alongside @supabase/ssr). Do not generate Pages Router or @supabase/auth-helpers-nextjs. When to keep middleware.ts, and when to migrate it to proxy.ts, is covered on the proxy page.

params and searchParams are Promises. Always await them. The sample page types params as Promise<{ id: string }>, awaits that promise, and then renders id. cookies(), headers(), and draftMode() from next/headers are async. Await them on every call. Server Components are the default. Add "use client" only when the file uses state, effects, browser APIs, or event handlers. Push that file to a leaf component.

New create-next-app projects enable Cache Components. Do not cache a response that depends on a cookie or a user. Authenticated reads stay dynamic. Read the cookie with await cookies() inside the component that needs it, and do not store that result on a cached response. Browser code uses createBrowserClient. Server Components, Server Actions, and Route Handlers use createServerClient with cookies.getAll and cookies.setAll.

Awaiting cookies() does not decide whether the request is allowed. To decide whether a request is allowed, call supabase.auth.getClaims(). Use getSession() only to read the raw token, and never trust session.user for authorization. The done checklist is npx tsc --noEmit and next build pass, or you said why they could not run. New tables have RLS enabled plus policies, in a migration file. No getSession() is used for authorization, and no select("*") was added.

Last verified 2026-11-04. doc-verified; TypeScript snippets pass tsc --strict (TypeScript 5, @types/react 19) with zod and the Supabase client stubbed.

Pro

Next.js 16 + Supabase Pro rules, $1+

$1+ · pay what you want

RLS policy recipes, getClaims, Stripe webhooks, and Cache Components. Deeper than the free Next.js + Supabase pack.

Each pack ships as AGENTS.md, CLAUDE.md, Cursor .mdc, and Copilot instructions, with 12 months of free updates.

From the Next.js 16 + Supabase Pro rules

Enable RLS on every table in `public`. A table with no policy denies that command for `anon` and `authenticated`. A table with RLS off is readable and writable through the Data API. The free pack already says this. Write the policy, do not stop at `enable row level security`.
Name the role with `to authenticated`. Compare `(select auth.uid())` to `user_id`. The `select` wrapper is the form in the Supabase RLS guide. `auth.uid()` is null when the JWT is missing, and `null = user_id` is never true.
`select` and `delete` use `using`. `insert` uses `with check`, so a user cannot insert a row for someone else. `update` uses both: `using` picks the row, `with check` locks the row after the write, including `user_id`.
The secret key, and the legacy `service_role` key, bypass RLS. Use one only on the server, after you have checked the caller yourself. A browser client never gets that key. Supabase also says a secret key does not bypass RLS when the request still carries a user access token.
Buy Pro — $1+

Next.js + Supabase pack — Rules pinned to Next.js 16 and Supabase SSR — the APIs that actually work with React 19. Same advice in all four agent file formats, snippet-checked.

doc-verified; TypeScript snippets pass tsc --strict (TypeScript 5, @types/react 19) with zod and the Supabase client stubbed

Sample from the pack

The page sample in the Next.js + Supabase rules file.

export default async function Page({
  params,
}: {
  params: Promise<{ id: string }>
}) {
  const { id } = await params
  return <h1>{id}</h1>
}

Sources in the pack

Questions

Are params and cookies() synchronous in Next.js 16?
In Next.js 16 params and searchParams are Promises. Always await them. cookies(), headers(), and draftMode() from next/headers are async. Await them. Synchronous access typechecks in places and crashes at runtime.
How do I read params in Next.js 16?
params and searchParams are Promises. Always await them. The sample page types params as Promise<{ id: string }>, awaits that promise, and then renders id. Synchronous access typechecks in places and crashes at runtime.
Are cookies(), headers(), and draftMode() async in Next.js 16?
Yes. cookies(), headers(), and draftMode() from next/headers are async. Await them. Do not cache a response that depends on a cookie or a user. Authenticated reads stay dynamic.
When was this Next.js 16 params rule last checked?
Last verified 2026-11-04. doc-verified; TypeScript snippets pass tsc --strict (TypeScript 5, @types/react 19) with zod and the Supabase client stubbed.