Performance: Catch-all routes with [...param]
MEDIUM IMPACT
This affects page load speed and routing performance by how Next.js matches and renders dynamic routes.
pages/[...param].js import { useMemo } from 'react'; export default function Page({ params }) { const path = useMemo(() => params.param?.join('/') ?? '', [params.param]); return <div>{path}</div>; } export async function getStaticPaths() { return { paths: [], fallback: 'blocking' }; } export async function getStaticProps({ params }) { // fetch minimal data return { props: { params } }; }
pages/[...param].js export default function Page({ params }) { // heavy logic to parse params and fetch data return <div>{params.param?.join('/')}</div>; } // No caching or static optimization
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Catch-all route without static paths | Minimal DOM nodes | 1 reflow on render | Low paint cost | [!] OK |
| Catch-all route with getStaticPaths and fallback blocking | Minimal DOM nodes | 1 reflow on render | Low paint cost | [OK] Good |