rsnext/errors/prerender-error.mdx
Lee Robinson 83bd0f43e1
docs: improve prerender error message (#64154)
Based on customer feedback

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-07 09:46:13 -05:00

18 lines
1.4 KiB
Text

---
title: Prerender Error
---
## Why This Error Occurred
While prerendering a page an error occurred. This can occur for many reasons from adding non-pages e.g. `components` to your `pages` folder or expecting props to be populated which are not.
## Possible Ways to Fix It
- Use Next.js 13 (or higher) and the [App Router](/docs#app-router-vs-pages-router), which allows [colocation](/docs/app/building-your-application/routing#colocation) of pages and other files (e.g. components, styles, tests, etc)
- Make sure to move any non-pages out of the `pages` folder
- Check for any code that assumes a prop is available, even when it might not be
- Set default values for all dynamic pages' props (avoid `undefined`, use `null` instead so it can be serialized)
- Check for any out of date modules that you might be relying on
- Make sure your component handles `fallback` if it is enabled in `getStaticPaths`. [Fallback docs](/docs/pages/api-reference/functions/get-static-paths#fallback-false)
- Make sure you are not trying to export (`output: 'export'` or `next export`) pages that have server-side rendering enabled [`getServerSideProps`](/docs/pages/building-your-application/data-fetching/get-server-side-props)
- If necessary, you can [disable server-side rendering](/docs/pages/building-your-application/optimizing/lazy-loading#with-no-ssr) for a specific component that may be attempting to use browser APIs like `window`