T
TanStack3w ago
wise-white

How to redirect and pass search params?

I have a legacy route that has to be redirected to a new route, and I need to pass all search params passed to that route, how do I achieve this using a zod validator?
4 Replies
inland-turquoise
inland-turquoise2w ago
throw a redirect in its beforeLoad
optimistic-gold
optimistic-gold2w ago
Oh, I have a similar case! I have legacy search params, and I want to remove them from the URL if they don’t pass up-to-date validation. Is it possible to trigger a redirect from validateSearch to do that? Or is there a better way?
wise-white
wise-whiteOP2w ago
Just doing a redirect removes all search params though
beforeLoad: () => {
throw redirect({
to: '/other-url',
search: prev => prev
});
}
beforeLoad: () => {
throw redirect({
to: '/other-url',
search: prev => prev
});
}
Does the trick
inland-turquoise
inland-turquoise2w ago
search: true should work too

Did you find this page helpful?