Route used `cookies().get(...)`. `cookies()` should be awaited before using its properties

Filed under Next.js & React errors

Most likely causeAbout 10 min · 6 steps

In Next.js 15, cookies() from next/headers returns a promise instead of the cookie store, so reading it without await triggers the error.

Await cookies() in an async function
Fix the Supabase client helper
Await every call site

Fastest route

Give your AI this prompt

Copy it, replace the bracketed part with your error, and send it.

Preview the prompt
My Next.js 15 app logs this error: "Route '/[paste your route]' used `cookies().get(...)`. `cookies()` should be awaited before using its properties." (It may also name headers() or draftMode(), or mention sync-dynamic-apis.)

Here is the file the error points at, and my server client helper if I have one (for example utils/supabase/server.ts): [paste the files].

Please: 1) await cookies() and make every function that contains the call async, adding await at each call site of those functions, 2) if the file is a Supabase server client helper, make createClient() async and show me every place that must become await createClient(), 3) apply the same treatment to headers() and draftMode() if they appear, 4) search the rest of the project for un-awaited cookies(), headers(), or draftMode() calls and list them.

Constraints: do not move cookie-setting code into Server Components, do not change what the code does with the cookies, and do not change my auth flow — only how these APIs are awaited. Show me each file you change.

Fix it yourself

Follow the repair

  1. Await cookies() and make the enclosing function async. The core edit is two words — async on the function, await on the call:
    // Before (Next.js 14 style — triggers the error in 15)
    import { cookies } from "next/headers";
    
    export function getTheme() {
      return cookies().get("theme")?.value;
    }
    
    // After — same helper, awaited
    export async function getTheme() {
      const cookieStore = await cookies();
      return cookieStore.get("theme")?.value;
    }
    Every caller of that helper now needs await in front of it as well — expect a short chain of these edits, and let TypeScript point you to each one.
  2. Apply it in Server Components, Route Handlers, and Server Actions alike. The rule does not change with the room you are standing in: anywhere server-side code calls cookies(), the function holding the call becomes async and the call is awaited. In a Server Action that logs a user in, for example, it looks like const cookieStore = await cookies(); cookieStore.set("session", token); at the top of the action.
  3. Fix the Supabase server client helper — the usual real culprit. If your app uses Supabase auth, open the file that creates the server client (commonly utils/supabase/server.ts). Make createClient async and await cookies() inside it:
    import { createServerClient } from "@supabase/ssr";
    import { cookies } from "next/headers";
    
    export async function createClient() {
      const cookieStore = await cookies();
      return createServerClient(/* your URL and key */, {
        cookies: {
          getAll() { return cookieStore.getAll(); },
          setAll(cookiesToSet) {
            cookiesToSet.forEach(({ name, value, options }) =>
              cookieStore.set(name, value, options));
          },
        },
      });
    }
    Then find every place that calls createClient() and await it: const supabase = await createClient();. Miss one call site and the error survives there.
  4. Give headers() and draftMode() the identical treatment. They changed in the same release: const headersList = await headers(); and const draft = await draftMode();. If the console shows the error naming headers instead of cookies, it is this step, not a new problem.
  5. Know the separate trap: setting cookies while rendering. Reading cookies in a Server Component is fine once awaited, but setting or deleting them is only allowed in a Server Action or a Route Handler. If your error says cookies can only be modified in a Server Action or Route Handler, that is a different message with a different fix — move the .set() call out of the component render and into an action or handler. Do not chase it with more awaits.
  6. Sweep the project, or run the codemod. Search for cookies(), headers(), and draftMode() and check each call is awaited inside an async function. On a larger upgraded project, the official codemod does the common patterns for you: npx @next/codemod@canary next-async-request-api — then search anyway for the @next-codemod-error comments it leaves where it could not rewrite safely.
Why this happensOptional explanation

cookies() is one of a small family of Next.js features called the Dynamic APIs — the ones that read information from the incoming request. In Next.js 15 the whole family went asynchronous: the params and searchParams props, and cookies(), headers(), and draftMode() from next/headers. Next.js made the change so pages can start rendering before every request detail is resolved. In Next.js 14, cookies() handed you the cookie store on the spot. In 15 it hands you a promise of the store, and reading .get(), .set(), or .delete() on that promise — or spreading or looping over it — is what triggers the error.

The reason this one feels different from the params error is where it lives. params appears in pages you can see; cookies() lives in plumbing — middleware helpers, auth utilities, and the Supabase server client file that AI builders generate once and every page quietly depends on. Fix the helper wrong and the error multiplies across routes; fix it once, properly, and it disappears everywhere at the same time. In current Next.js 15 versions the old synchronous access still works after logging the error, but that grace period is ending — the access is being removed, so an app that ignores this will break on a future upgrade.

  • Upgraded from Next.js 14: every cookies() call predates the change and reads the store synchronously.
  • The Supabase server client helper: utils/supabase/server.ts and its cousins call cookies() inside a non-async createClient() — the single most common hiding place.
  • AI-generated auth boilerplate: AI builders reproduce the Next.js 14 pattern from memory, even in brand-new projects.
  • headers() and draftMode() too: the same change, the same error shape, often lurking in the same files.

Quick answers

My error comes from my Supabase server client file. Is it the same fix?

Yes — that helper is the most common source of this error, because it calls cookies() inside a createClient() that was written for Next.js 14. Make createClient async, await cookies() inside it, and then await createClient() at every call site. One file fixed properly clears the error across every route that uses it.

Does headers() have the same problem?

It is the same change: in Next.js 15, cookies(), headers(), and draftMode() from next/headers all became asynchronous, alongside the params and searchParams props. Whichever one the error names, the fix is identical — await it inside an async function.

Can I set cookies in a Server Component once I await them?

No — reading and setting are different rules. Once awaited, reading cookies works in Server Components, Route Handlers, and Server Actions. Setting or deleting cookies is only allowed in a Server Action or a Route Handler; doing it during a Server Component render produces a different error with its own message.

One fix, every Friday.

One real error, explained in plain English, with the fix — in your inbox every Friday. No spam, no jargon, unsubscribe anytime. Every issue closes with a verse and a word of encouragement.