2022-12-11 21:27:57 +00:00
---
2023-10-18 10:59:43 +00:00
title: 'preloadRouteComponents'
description: preloadRouteComponents allows you to manually preload individual pages in your Nuxt app.
links:
- label: Source
icon: i-simple-icons-github
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/preload.ts
size: xs
2022-12-11 21:27:57 +00:00
---
2023-10-18 10:59:43 +00:00
Preloading routes loads the components of a given route that the user might navigate to in future. This ensures that the components are available earlier and less likely to block the navigation, improving performance.
2022-12-11 21:27:57 +00:00
2024-09-17 15:33:49 +00:00
::tip{icon="i-ph-rocket-launch" color="gray"}
2022-12-11 21:27:57 +00:00
Nuxt already automatically preloads the necessary routes if you're using the `NuxtLink` component.
::
2023-10-18 10:59:43 +00:00
:read-more{to="/docs/api/components/nuxt-link"}
2022-12-11 21:27:57 +00:00
## Example
Preload a route when using `navigateTo` .
```ts
// we don't await this async function, to avoid blocking rendering
// this component's setup function
preloadRouteComponents('/dashboard')
const submit = async () => {
const results = await $fetch('/api/authentication')
if (results.token) {
await navigateTo('/dashboard')
}
}
```
2023-10-18 10:59:43 +00:00
:read-more{to="/docs/api/utils/navigate-to"}
2022-12-11 21:27:57 +00:00
2024-02-21 17:09:45 +00:00
::note
2023-10-18 10:59:43 +00:00
On server, `preloadRouteComponents` will have no effect.
2022-12-11 21:27:57 +00:00
::