Recall & Review
beginner
What is a dynamic route in Next.js?
A dynamic route in Next.js is a page route that uses square brackets [param] in the filename to capture variable parts of the URL, allowing the page to render different content based on the URL segment.
Click to reveal answer
beginner
How do you define a dynamic route for a user profile page with a user ID in Next.js?
You create a file named [userId].js inside the pages or app directory. The [userId] part captures the user ID from the URL, like /profile/123, where 123 is the userId.
Click to reveal answer
intermediate
How do you access the dynamic parameter inside a Next.js page component?
You use the useRouter hook from 'next/router' or the params object in server components to get the dynamic parameter value from the URL.
Click to reveal answer
beginner
What is the difference between a static route and a dynamic route in Next.js?
A static route has a fixed path like /about, while a dynamic route uses [param] to match many paths like /product/1, /product/2, where the param changes.
Click to reveal answer
intermediate
Can you have multiple dynamic segments in a Next.js route? How?
Yes, you can have multiple dynamic segments by naming files like [category]/[id].js. This captures two parameters from the URL, for example /books/123.
Click to reveal answer
What does the file name [postId].js represent in Next.js routing?
✗ Incorrect
Files with [param] in their name define dynamic routes that capture the param value from the URL.
How do you get the value of a dynamic route parameter inside a client component?
✗ Incorrect
The useRouter hook provides access to the dynamic route parameters in client components.
Which URL matches the dynamic route file [category]/[id].js?
✗ Incorrect
The URL /books/123 matches the dynamic segments category=books and id=123.
What happens if you visit a dynamic route URL that does not match any file?
✗ Incorrect
If no matching route file exists, Next.js shows the 404 not found page.
Can dynamic routes be nested inside folders in Next.js?
✗ Incorrect
Dynamic routes can be nested inside folders to create complex URL structures.
Explain how to create and use a dynamic route with [param] in Next.js.
Think about how the file name relates to the URL and how to get the value inside the component.
You got /4 concepts.
Describe the difference between static and dynamic routes in Next.js and when to use each.
Consider how URLs look and what content changes.
You got /4 concepts.