Skip to content

routePath

Description

Utility function to construct a routing path along with its parameters.

Import

import { routePath } from "dreamkit";

Definition

declare const routePath: (path: string, params?: Record<string, any>) => string;

Examples

Basic usage

import { $route, routePath, s } from "dreamkit";
export const userRotue = $route
.params({ id: s.number() })
.path(({ id }) => `/users/${id}`)
.create(({ params }) => <>{params.id}</>);
export default $route.path("/").create(() => {
return <a href={routePath("/users/:id", { id: 1 })}>User 1</a>;
});