docs: add more documentation for pages:routerOptions

This commit is contained in:
Daniel Roe 2024-01-29 20:31:39 +00:00
parent b0f50bec1b
commit 46b5336718

View File

@ -92,6 +92,27 @@ export default <RouterConfig> {
}
```
It is possible to add more router options files by adding files within the `pages:routerOptions` hook.
::alert
Adding a router options file in this hook will switch on page-based routing, unless `optional` is set, in which case it will only apply when page-based routing is already enabled.
::
```ts [nuxt.config.ts]
export default defineNuxtConfig({
hooks: {
'pages:routerOptions' ({ files }) {
const resolver = createResolver(import.meta.url)
// add a route
files.push({
path: resolver.resolve('./runtime/app/router-options')
optional: true
})
}
}
})
```
### Using `nuxt.config`
**Note:** Only JSON serializable [options](/docs/api/nuxt-config#router) are configurable: