docs: selective pre-rendering options (#20670)

This commit is contained in:
Clément Ollivier 2023-05-04 12:52:46 +02:00 committed by GitHub
parent 47591c92ec
commit 30132f3603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 1 deletions

View File

@ -87,7 +87,19 @@ Use the [`nuxi generate` command](/docs/api/commands/generate) to build your app
npx nuxi generate
```
### Manual Pre-rendering
You can enable crawl-based pre-rendering when using `nuxt build` in the `nuxt.config` file:
```ts [nuxt.config.ts|js]
defineNuxtConfig({
nitro: {
prerender: {
crawlLinks: true
}
}
})
```
### Selective Pre-rendering
You can manually specify routes that [Nitro](/docs/guide/concepts/server-engine) will fetch and pre-render during the build.
@ -101,6 +113,20 @@ defineNuxtConfig({
})
```
When using this option with `nuxi build`, static payloads won't be generated by default at build time. For now, selective payload generation is under an experimental flag.
```ts [nuxt.config.ts|js]
defineNuxtConfig({
/* The /dynamic route won't be crawled */
nitro: {
prerender: { crawlLinks: true, ignore: ['/dynamic'] }
},
experimental: {
payloadExtraction: true
}
})
```
### Client-side Only Rendering
If you don't want to pre-render your routes, another way of using static hosting is to set the `ssr` property to `false` in the `nuxt.config` file. The `nuxi generate` command will then output an `.output/public/index.html` entrypoint and JavaScript bundles like a classic client-side Vue.js application.