Optional locale param with wildcard
I have
/{$-lang}/$ -like routes.
When user access /hello page, how would router know that "hello" is not a lang? Do I need to manually check and somehow redirect to the splat route?
I tried to do:
but that would send the server into infinite loop.4 Replies
extended-salmonOP•2mo ago
Anyone? Kindly bump
I got the workaround. I'm not sure if it Start-specific or Router specific, but I'll post that here just in case somebody has similar usecase. The key is to set
rewrite of the createRouter.
router.tsx
stormy-gold•2mo ago
you should look into params.parse
might just do the trick for validating the actual language
extended-salmonOP•2mo ago
Would that mean that accessing
/hello would throw an error then? I just need the router to assume that the lang in undefined and skip to the wildcard route..
Docs :If this function throws, the route will be put into an error state and the error will be thrown during render.RouteOptions type | TanStack Router React Docs
The RouteOptions type is used to describe the options that can be used when creating a route. RouteOptions properties The RouteOptions type accepts an object with the following properties: getParentRo...
stormy-gold•2mo ago
do you have a minimal complete example ?