The Nitro crawler works by:
- Loading the HTML of your root route and any non-dynamic pages
- Saving the HTML and payload
- Finding all anchor tags to navigate to other routes
- Repeating the process for each discovered route
If your dynamic pages aren't linked from any discoverable page, they won't be automatically prerendered Link to Nuxt Docs.
Manually Specify Routes to Prerender
For dynamic routes that might not be discoverable through crawling, you can manually specify them:
export default defineNuxtConfig({
nitro: {
prerender: {
routes: ['/your-dynamic-route/1', '/your-dynamic-route/2'],
},
},
});
Use prerenderRoutes Helper
You can also use the prerenderRoutes helper in your components to hint additional routes for prerendering:
<script setup>
prerenderRoutes(['/your-dynamic-route/1', '/your-dynamic-route/2']);
</script>
Note that this only works if the component containing this code is itself prerendered Link to Nuxt Docs.
Check for Prerendering Issues
Make sure that your GraphQL queries are being properly executed during the build process. If there are any errors or timeouts during the build, some routes might not be properly prerendered.
Also, ensure that your dynamic routes are properly configured and that the data needed for prerendering is available at build time.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: