T
TanStack16mo ago
ambitious-aqua

pass a “state” when using “navigate()”

Hey, Thanks for all the help with the previous question. Now to the next one: After sign up I’m redirecting user to “sign in” page using “navigate({to: “/sign-in”})”. I want to display some kind of toaster for users that just signed up and are on sign in page to inform them to check the email. I would like to pass some kind of “state” param when doing “navigate(…)” and the read this state on the sign-in page. I would like to not do this using search params but rather to keep it hidden to the end user. Thanks for all your help!
4 Replies
fascinating-indigo
fascinating-indigo16mo ago
you could use a search param but hide it using route masking
ambitious-aqua
ambitious-aquaOP16mo ago
Just found out about that and it's 100% my case
rare-sapphire
rare-sapphire15mo ago
Couldn't you use the actual state param?
ambitious-aqua
ambitious-aquaOP15mo ago
By writing state param I meant something like in react-router-dom:
<div onClick={() => {
nav("/some-where", { state:data});
}}>Click me</div>
<div onClick={() => {
nav("/some-where", { state:data});
}}>Click me</div>
^ this could be accessed later by react-router-dom's useLocation hook. I was not able to do the same in tanstack-router

Did you find this page helpful?