docs: add router.extendRoutes example to migration docs (#4023)

* docs: add `router.extendRoutes` example to migration docs

* style: lint
This commit is contained in:
Daniel Roe 2022-04-01 14:21:06 +01:00 committed by GitHub
parent 1890c55cbe
commit 59b319b492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,7 @@ Nuxt configuration will be loaded using [`unjs/jiti`](https://github.com/unjs/ji
### Migration
You should migrate to the new `defineNuxtConfig` function that provides a typed configuration schema.
1. You should migrate to the new `defineNuxtConfig` function that provides a typed configuration schema.
::code-group
@ -31,6 +31,36 @@ export default defineNuxtConfig({
})
```
::
1. If you were using `router.extendRoutes` you can migrate to the new `pages:extend` hook:
::code-group
```ts [Nuxt 2]
export default {
router: {
extendRoutes (routes) {
//
}
}
}
```
```ts [Nuxt 3]
import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig({
hooks: {
'pages:extend' (routes) {
//
}
}
})
```
::
#### ESM Syntax
Nuxt 3 is an [ESM native framework](/concepts/esm). Although [`unjs/jiti`](https://github.com/unjs/jiti) provides semi compatibility when loading `nuxt.config` file, avoid any usage of `require` and `module.exports` in this file.