Next.js 15: “params should be awaited” and “cookies() should be awaited”
Error message: params should be awaited before using its properties
In Next.js 15, request-specific APIs became asynchronous. Code written for Next.js 14 still runs for now, but it logs warnings like:
Route "/blog/[slug]" usedparams.slug.paramsshould be awaited before using its properties.
It also affects searchParams, cookies(), headers() and draftMode().
Pages and layouts
params and searchParams are now Promises:
// app/blog/[slug]/page.tsx
export default async function Page({
params,
searchParams
}: {
params: Promise<{ slug: string }>;
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}) {
const { slug } = await params;
const { page = "1" } = await searchParams;
return <h1>{slug}, page {page}</h1>;
}The same applies to generateMetadata and to layouts.
Route handlers
The second argument's params is a Promise too:
// app/api/posts/[id]/route.ts
export async function GET(req: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return Response.json({ id });
}cookies() and headers()
import { cookies, headers } from "next/headers";
const cookieStore = await cookies();
const theme = cookieStore.get("theme")?.value;
const ua = (await headers()).get("user-agent");If you use Supabase on the server, update your helper so it awaits cookies() before creating the client, and make the helper itself async.
Client Components
A Client Component can't be async. Unwrap the Promise with React's use, or read the values with hooks:
"use client";
import { use } from "react";
import { useParams } from "next/navigation";
export default function Page({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = use(params); // or: const { slug } = useParams<{ slug: string }>();
return <p>{slug}</p>;
}Let a codemod do most of it
Next.js ships a codemod that rewrites most of these cases for you:
npx @next/codemod@canary next-async-request-api .Commit first, run it, then search the result for comments the codemod leaves where it couldn't decide.