Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions errors/next-dynamic-api-wrong-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export async function GET() {
}
```

## `generateStaticParams`

Request-time APIs like `headers()`, `cookies()`, `connection()`, and `draftMode()` are not available inside `generateStaticParams` because it runs at build time to determine which pages to statically generate. There is no HTTP request in this context.

Note: Root param getters (`import { lang } from 'next/root-params'`) _are_ supported inside `generateStaticParams` for nested segments, as the parent params are known at that point.

## Useful Links

- [`headers()` function](/docs/app/api-reference/functions/headers)
Expand Down
18 changes: 17 additions & 1 deletion packages/next/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1117,5 +1117,21 @@
"1116": "Route \"%s\" accessed header \"%s\" which is not defined in the \\`samples\\` of \\`unstable_instant\\`. Add it to the sample's \\`headers\\` array, or \\`[\"%s\", null]\\` if it should be absent.",
"1117": "Instant validation boundaries should never appear in browser bundles.",
"1118": "An error occurred while attempting to validate instant UI. This error may be preventing the validation from completing.",
"1119": "Expected edge function entrypoint to emit a JavaScript file"
"1119": "Expected edge function entrypoint to emit a JavaScript file",
"1120": "createServerParamsForServerSegment should not be called inside generateStaticParams.",
"1121": "Route %s used \\`%s\\` inside \\`generateStaticParams\\`. This is not supported because \\`generateStaticParams\\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"1122": "createParamsFromClient should not be called inside generateStaticParams.",
"1123": "Route %s used \\`cookies()\\` inside \\`generateStaticParams\\`. This is not supported because \\`generateStaticParams\\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"1124": "createPrerenderSearchParamsForClientPage should not be called inside generateStaticParams.",
"1125": "Route %s used \\`connection()\\` inside \\`generateStaticParams\\`. This is not supported because \\`generateStaticParams\\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"1126": "createPrerenderParamsForClientSegment should not be called inside generateStaticParams.",
"1127": "Route %s used \"%s\" inside \\`generateStaticParams\\` which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"1128": "createServerSearchParamsForServerPage should not be called inside generateStaticParams.",
"1129": "createServerPathnameForMetadata should not be called inside generateStaticParams.",
"1130": "\\`%s\\` was called in \\`generateStaticParams\\`. Next.js should be preventing %s from being included in server component files statically, but did not in this case.",
"1131": "createServerParamsForRoute should not be called inside generateStaticParams.",
"1132": "Route %s used \\`draftMode()\\` inside \\`generateStaticParams\\`. This is not supported because \\`generateStaticParams\\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"1133": "createSearchParamsFromClient should not be called inside generateStaticParams.",
"1134": "Route %s used \\`headers()\\` inside \\`generateStaticParams\\`. This is not supported because \\`generateStaticParams\\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context",
"1135": "\"use cache\" cannot be used outside of App Router. Expected a WorkUnitStore."
}
Loading
Loading