DEV Community

Snehendu Roy
Snehendu Roy

Posted on

Fallback true returns error while deployment

Next Js by itself is a super power over react. With its functions like getStaticPaths() and getDtaticProps(), dynamic page generation becomes truly easy.

But in most cases, fallback true returns error during deployment

export async function getStaticPaths() {
   returns {
     paths: paths, 
     fallback: true // returns error
   }
}
Enter fullscreen mode Exit fullscreen mode

To solve this, you must handle the data coming from getStaticProps() in your component

export default function App({data}) {
  if (!data) return null;
}
Enter fullscreen mode Exit fullscreen mode

This simple one liner, at the top of your component page where getStaticPaths()is used, can fix all the problems regarding this during deployment.

Top comments (0)