docs: add example on how to disable default routes for ssg (#30729)

This commit is contained in:
Alan Schio 2025-01-24 10:42:05 -04:00 committed by Daniel Roe
parent cb7f30a1ea
commit 94ba2ea0b6
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -126,6 +126,26 @@ This will produce three files:
The `200.html` and `404.html` might be useful for the hosting provider you are using.
#### Skipping Client Fallback Generation
When prerendering a client-rendered app, Nuxt will generate `index.html`, `200.html` and `404.html` files by default. However, if you need to prevent any (or all) of these files from being generated in your build, you can use the `'prerender:generate'` hook from [Nitro](/docs/getting-started/prerendering#prerendergenerate-nitro-hook).
```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({
ssr: false,
nitro: {
hooks: {
'prerender:generate'(route) {
const routesToSkip = ['/index.html', '/200.html', '/404.html']
if (routesToSkip.includes(route.route)) {
route.skip = true
}
}
}
}
})
```
## Hybrid Rendering
Hybrid rendering allows different caching rules per route using **Route Rules** and decides how the server should respond to a new request on a given URL.