Problem Statement
What does getStaticProps do in Next.js?
Explanation
getStaticProps runs at build time during next build to fetch data that will be baked into the HTML pages, allowing you to pre-render pages with data from APIs, databases, or the filesystem for maximum performance. The function only runs on the server and never in the browser, letting you safely use server-only code like database queries or reading the filesystem. Combined with ISR revalidation, getStaticProps enables static pages that can update periodically without rebuilding the entire site.
Practice Sets
This question appears in the following practice sets: