generatePath
On this page

generatePath

Summary

Reference Documentation ↗

Returns a path with params interpolated.

import { generatePath } from "react-router";  generatePath("/users/:id", { id: "123" }); // "/users/123" 

Signature

function generatePath<Path extends string>(  originalPath: Path,  params: {  [key in PathParam<Path>]: string | null;  } = as any, ): string {} 

Params

originalPath

The original path to generate.

params

The parameters to interpolate into the path.

Returns

The generated path with parameters interpolated.

Docs and examples CC 4.0
Edit