Capturé

Segments capturés de deeply/nested/path/that/keeps/going.

Astuce
props.params.slug peut arriver soit comme chaîne (avec des séparateurs /) soit comme tableau selon le moteur de rendu — défendez-vous toujours avec Array.isArray(raw) avant de le parcourir.

props.params bruts

paramvalue
slug"deeply/nested/path/that/keeps/going"

Segments (6)

  1. deeply
  2. nested
  3. path
  4. that
  5. keeps
  6. going
src/app/examples/catch/[...slug]/page.tsxTSX
// props.params.slug holds every segment after the prefix,
    // joined by "/" — split it to get an array.
export default function Page(props: PageProps): any {
            const raw = props.params.slug;
            const segments = Array.isArray(raw)
                            ? raw
                            : String(raw).split("/").filter(Boolean);
            return (
                            <ol>
                                            {segments.map((s) => <li>{s}</li>)}
                            </ol>
            );
}

← retour à l'index fourre-tout