Complete the code to export a function that generates static params for dynamic routes.
export async function [1]() { return [ { id: '1' }, { id: '2' } ]; }
The correct function to generate static params for Next.js dynamic routes in the App Router is generateStaticParams.
Complete the code to return static params with a dynamic segment named 'slug'.
export async function generateStaticParams() {
return [
{ [1]: 'post-1' },
{ slug: 'post-2' }
];
}The dynamic segment in the route is named 'slug', so the object keys must be 'slug'.
Fix the error in the generateStaticParams function to correctly return params for a dynamic route with 'category'.
export async function generateStaticParams() {
return [
{ [1]: 'tech' },
{ category: 'life' }
];
}In Next.js App Router, generateStaticParams returns an array of objects with keys matching the dynamic segment name directly, not nested inside 'params'.
Fill both blanks to generate static params for a dynamic route with segments 'year' and 'month'.
export async function generateStaticParams() {
return [
{ [1]: '2023', [2]: '06' },
{ year: '2024', month: '01' }
];
}The keys must match the dynamic route segments 'year' and 'month' exactly.
Fill all three blanks to generate static params for a dynamic route with segments 'category', 'id', and 'slug'.
export async function generateStaticParams() {
return [
{ [1]: 'news', [2]: '123', [3]: 'breaking-story' },
{ category: 'blog', id: '456', slug: 'hello-world' }
];
}Each key must match the dynamic segment names exactly: 'category', 'id', and 'slug'.