T
TanStack7mo ago
fascinating-indigo

is it possible to wildcat in Route Masking?

I want to create a masking that works for all routes. i have a global dialog that is based on query params and i don't want this query to always reflect in the url, how can i implement this? i.e 1. '/patient/?form=true' ::: '/patient' 2. '/calendar/?form=true' ::: '/calendar'
7 Replies
probable-pink
probable-pink7mo ago
what you mean by "always"?
probable-pink
probable-pink7mo ago
Route Masking | TanStack Router React Docs
Route masking is a way to mask the actual URL of a route that gets persisted to the browser's history and URL bar. This is useful for scenarios where you want to show a different URL than the one that...
fascinating-indigo
fascinating-indigoOP7mo ago
Yes ... but the issue is, i have to provide 'from' and 'to' which i want it to be global. This query '?form=true' appears in almost all my routes
const photoModalToPhotoMask = createRouteMask({
routeTree,
from: '*',
to: '*',
params: (prev) => ({
form: prev.form,
}),
})
const photoModalToPhotoMask = createRouteMask({
routeTree,
from: '*',
to: '*',
params: (prev) => ({
form: prev.form,
}),
})
Which i will expect it to globally works for all my routes. The use case here perfectly works for a single route, but in my case i have more that 40 routes that will have the same query. It doesn't make sense to create all 40 one after the other. What do you think?
probable-pink
probable-pink7mo ago
Search middleware to strip search params | TanStack Router React Docs
stripSearchParams is a search middleware that allows to remove search params. stripSearchParams props stripSearchParams accepts one of the following inputs: true: if the search schema has no required...
fascinating-indigo
fascinating-indigoOP7mo ago
No ... this is not masking. is there a way to get all available routes, maybe i can map through and return createRouteMask of each route. So sorry, i'm very new here.
probable-pink
probable-pink7mo ago
yes you can map over router.routesByPath or routesById
fascinating-indigo
fascinating-indigoOP7mo ago
Thanks. I appreciate

Did you find this page helpful?