From the course: Learning Next.js
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Pre-rendering at build time with static paths
From the course: Learning Next.js
Pre-rendering at build time with static paths
- [Instructor] We continue with the example of getStaticPath, and what we're going to be doing here is to allow to statically generate content that we're going to use, depending on the path that we navigate to. So, I'm going to be using a switch case. And this switch case will take, actually, remember that we're using dynamic routes. So we're using this here placeholder. So we're going to access this one params query from params, so that it's going to be params.path, like this. And inside the switch case, we're going to have two case. First, one that corresponds to a predefined path, which is top stories. And another one which is to display the popular stories. And no. So that's actually here, the two dots. And after that, you can return to whichever results you get back from the API call. So we're going to return this with the object, props. Same here for the popular. And for any switch case, you always have a default…
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
-
-
-
-
-
Discovering the rendering strategies3m 51s
-
(Locked)
Discovering the rendering strategies with getStaticProps4m 17s
-
(Locked)
Pre-rendering at build time with static generation4m 32s
-
(Locked)
Pre-rendering super fast and super SEO-efficient content3m 17s
-
(Locked)
Discovering the rendering strategies with getServerSideProps4m 15s
-
(Locked)
Using dynamic routes and user's input to query content3m 51s
-
(Locked)
Search, request, and pre-render content with SSR2m 18s
-
(Locked)
Discovering the rendering strategies with getStaticPaths3m 47s
-
(Locked)
Pre-rendering at build time with static paths5m 9s
-
(Locked)
Handling errors with a fallback page (404 not found)2m 59s
-
(Locked)
Customizing an error page2m 16s
-
(Locked)
Challenge: Pre-rendering at build vs. runtime4m 25s
-
(Locked)
Solution: Pre-rendering at build vs. runtime8m 57s
-
-
-