How to debug getStaticProps (and getStaticPaths) in Next.js How to debug getStaticProps (and getStaticPaths) in Next.js reactjs reactjs

How to debug getStaticProps (and getStaticPaths) in Next.js


So after further research and testing I found out that getStaticProps() is only called on page components. So that was why I wasn't seeing any output. When I added the method to a component inside the pages directory I was able to see debug output produced with console.log() in the console running yarn dev on manual browser page refreshes (but not on automatic refreshes after modifying the page component) as well as during yarn build.


getStaticProps runs on the server-side and not on the client-side.

getStaticProps only runs on the server-side. It will never run on the client-side. It won’t even be included in the JS bundle for the browser.

Ref: https://nextjs.org/learn/basics/data-fetching/getstaticprops-details


Using the current next version (11.x) you can use console.log to print out any data in the getStaticProps() function.

You will see that output in the terminal where you run

   vercel dev