Next.js params Is a Promise
params holds the changing part of the address. In Next.js 15 and newer, params is a Promise, so it must be awaited.
The broken page reads params without await
The page takes params as a Promise. Then it reads id straight out of it, with no await.
export default async function BookPage({
params,
}: {
params: Promise<{ id: string }>;
}) {
const { id } = params;
const book = books.find((b) => b.id === id);The real type error
The type check names the exact line and the exact problem. The id is not there yet.
npx tsc --noEmitThe fix is one word
await opens the Promise. The rest of the page stays the same.
const { id } = await params;Example
const books = { "2": "Pride and Prejudice", "3": "The Hobbit" };
console.log("/books/2 → " + books["2"]);
console.log("/books/3 → " + books["3"]);
console.log("/books/999 → Book not found");Key points
- Promise: a value that is not ready yet. await waits for it.
- params has the type Promise<{ id: string }>. The id sits inside the Promise.
- Reading id without await fails the type check. The compiler reports the error.
- await params opens the Promise. Then id is a plain string.
- The fixed page shows Pride and Prejudice at /books/2 and The Hobbit at /books/3.
- A missing book shows "Book not found". /books/999 has no book behind it.
In this example, the fixed page answers three addresses. Book 2 is Pride and Prejudice, and book 3 is The Hobbit. Book 999 has no book behind it, so the page shows "Book not found". The fix was one word: await params before reading id.
Note
searchParams is a Promise too. It holds the question part of the address, and it needs the same await.
Try it Yourself
Edit the code, then press Run.
Running is simulated · TypeScript Playground
Exercise
What does the type checker say when you read id without await?