Skip to content

routePatternFromParams

routePatternFromParams(pathname, params): string | null

Rebuild the framework route PATTERN from a concrete pathname and the framework’s route params — the Next.js App Router recipe, without the SDK importing next/navigation:

React
'use client';
import { useParams, usePathname } from 'next/navigation';
import { RevTurbineRoute, routePatternFromParams } from '@revturbine/sdk';
export function RouteBoundary({ children }: { children: React.ReactNode }) {
const route = routePatternFromParams(usePathname(), useParams());
return <RevTurbineRoute route={route}>{children}</RevTurbineRoute>;
}

/projects/p_42/settings with { projectId: 'p_42' } becomes /projects/[projectId]/settings; a catch-all { slug: ['a', 'b'] } becomes [...slug]. The result is then normalized like any other route, so a segment the params did not name is still templated if it looks like an identifier.

string | null | undefined

Readonly<Record<string, string | readonly string[] | undefined>> | null | undefined

string | null