Skip to content

Commit 684b24b

Browse files
committed
docs: add export const dynamic = 'force-static' to Route Handlers example on Static Exports
1 parent fedee7d commit 684b24b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/01-app/02-guides/static-exports.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,19 @@ export default function Page() {
232232

233233
### Route Handlers
234234

235-
Route Handlers will render a static response when running `next build`. Only the `GET` HTTP verb is supported. This can be used to generate static HTML, JSON, TXT, or other files from cached or uncached data. For example:
235+
Route Handlers will render a static response when running `next build`. Only the `GET` HTTP verb is supported. This can be used to generate static HTML, JSON, TXT, or other files from cached or uncached data. Since Route Handlers are dynamic by default, you must explicitly mark the handler as static by adding `export const dynamic = 'force-static'` when a static export is enabled. For example:
236236

237237
```ts filename="app/data.json/route.ts" switcher
238+
export const dynamic = 'force-static'
239+
238240
export async function GET() {
239241
return Response.json({ name: 'Lee' })
240242
}
241243
```
242244

243245
```js filename="app/data.json/route.js" switcher
246+
export const dynamic = 'force-static'
247+
244248
export async function GET() {
245249
return Response.json({ name: 'Lee' })
246250
}

0 commit comments

Comments
 (0)