Nuxt/docs/3.api/3.utils/prerender-routes.md

27 lines
737 B
Markdown
Raw Normal View History

---
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.
::callout
`prerenderRoutes` can only be called within the [Nuxt context](/docs/guide/going-further/nuxt-app#the-nuxt-context).
::
```js
const route = useRoute()
prerenderRoutes('/')
prerenderRoutes(['/', '/about'])
```
::callout
In the browser, or if called outside prerendering, `prerenderRoutes` will have no effect.
::