From the course: Learning Next.js

Unlock the full course today

Join today to access over 22,800 courses taught by industry experts or purchase this course individually.

Discovering the rendering strategies with getStaticProps

Discovering the rendering strategies with getStaticProps

From the course: Learning Next.js

Start my 1-month free trial

Discovering the rendering strategies with getStaticProps

- [Instructor] We start with our first demonstration with data fetching with the function getStaticProps. And getStaticProps always runs on the server, never on the client side. And getStaticProps runs at build time when the HTML is ready, when you know that the content that you need to return is available ahead of the user's request, and this content is passed through this props return by this function, getStaticProps. So getStaticProps runs at build time, so when the application is being built, during the process of next/build. So when should you use getStaticProps? So this is when you know that the content is available ahead of the user's request and is ready to render, so no user input is required. This is useful for SEO optimization, when the HTML is rendered immediately. For example, from a headless CMS or a cached CDN. CDN for content delivery network. So for this example, we're going to head to the code editor,…

Contents