Next.js deployment error occurred prerendering page "/".

Troubleshoot - Next.js 13.2 deployment error on vercel

Today I was deploying Next.js 13.2 app on Vercel. It failed with an error Error occurred prerendering page "/"

I spent hours trying to identify the possible issue. The error for me was misleading. I tried the following solution

  • Make sure not to commit either .next or node_modules to avoid this behavior.

    • When you create the app using npx create-next-app@latest .gitignore already has these references hence I'm good here.
  • Check for any code that assumes a prop is available even when it might not be.

    • Did all the checks and functions were working for me.
  • Make sure your component handles fallback if it is enabled in getStaticPaths.

    • In Next.js 13.2 getStaticProps and getStaticPaths are not functional again no luck!

For me, the solution was to add the environment variables in Vercel!

Sometimes, the error message can be misleading! Hope these clues help you in your exploration in Next.js 13.2.

Happy Nexting! 🤓