From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
When to use GetStaticPropsServer with Next.js
From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
When to use GetStaticPropsServer with Next.js
Before we move on, we built a Markdown-based parsing algorithm. So we were just reading files with readdir sync. But if we were fetching asynchronously from our API, then we would want to use this await async pattern. And we would use something like fetch, which actually Next.js polyfills fetch for us. So you don't need to even import it, which is great. It just means that it's available for us in Next.js. But this is basically, you know, if you wanted to get sorted post data, instead of the file system, you fetch post data from an external API endpoint, you wait for the response, and then you return that response. You could also query a database directly. How would that look? Well, let's zoom out. One in doubt. So let's say we have some database SDK. So you bring in that library, create the client, and then you would run the query, select the posts and do whatever you'd want to do from the SDK. Now, of course, how do you figure out how to do that? Well, you got to go into the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Pre-rendering tests with Next.js6m 53s
-
(Locked)
What is static generation versus server-side rendering with Next.js?4m 17s
-
(Locked)
Static generation with data in Next.js4m 36s
-
(Locked)
Concise basic algorithms for Next.js practice and data processing20m 57s
-
(Locked)
Static generation and GetStaticProps with Next.js20m
-
(Locked)
When to use GetStaticPropsServer with Next.js3m 5s
-
(Locked)
SSR versus CSR and GetServerSideProps with Next.js7m 20s
-
(Locked)
-
-