mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-26 06:07:15 +00:00
31 lines
919 B
Markdown
31 lines
919 B
Markdown
---
|
|
title: 'prerenderRoutes'
|
|
description: prerenderRoutes hints to Nitro to prerender an additional route.
|
|
links:
|
|
- label: Source
|
|
icon: i-simple-icons-github
|
|
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/ssr.ts
|
|
size: xs
|
|
---
|
|
|
|
When prerendering, you can hint to Nitro to prerender additional paths, even if their URLs do not show up in the HTML of the generated page.
|
|
|
|
::important
|
|
`prerenderRoutes` can only be called within the [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context).
|
|
::
|
|
|
|
::note
|
|
`prerenderRoutes` has to be executed during prerendering. If the `prerenderRoutes` is used in dynamic pages/routes which are not prerendered, then it will not be executed.
|
|
::
|
|
|
|
```js
|
|
const route = useRoute()
|
|
|
|
prerenderRoutes('/')
|
|
prerenderRoutes(['/', '/about'])
|
|
```
|
|
|
|
::note
|
|
In the browser, or if called outside prerendering, `prerenderRoutes` will have no effect.
|
|
::
|