TanStackT
TanStack3y ago
4 replies
sacred-rose

Make a type safe URL string with params and searchParams so that users can copy i

Given a route, is there a way to create a strongly typed url string for users to copy?

const rootRoute = new RootRoute();
const publicUrl = new Route({
  getParentRoute: () => rootRoute,
  path: "/public/$id",
  ...
});

// Anything like this?
publicUrl.toString({ id: "f5ed9f10-345e-4164-9a8d-8f53a94de5d1" });
// outputs `/public/f5ed9f10-345e-4164-9a8d-8f53a94de5d1`
Was this page helpful?