Dynamic routes trong App Router sử dụng cú pháp folder name trong ngoặc vuông, ví dụ app/blog/[slug]/page.tsx sẽ match URL /blog/anything. Next.js 15: params là Promise — cần const { slug } = await params trong async Server Component, hoặc React.use(params) trong Client Component.
- Catch-all routes dùng app/[...slug]/page.tsx để match nhiều segments như /a/b/c (params.slug là mảng).
- Optional catch-all app/[[...slug]]/page.tsx còn match root route.
- TypeScript:
{ params: Promise<{ slug: string }> }cho dynamic route.
Dynamic routes use bracket folder names: app/blog/[slug]/page.tsx matches /blog/anything. Next.js 15: params is a Promise — use const { slug } = await params in async Server Components or React.use(params) in Client Components.
- Catch-all routes use spread syntax
app/[...slug]/page.tsxto match multiple segments (params.slugis an array). - Optional catch-all
app/[[...slug]]/page.tsxalso matches the root route. - TypeScript:
{ params: Promise<{ slug: string }> }for dynamic routes.