T
TanStack13mo ago
continuing-cyan

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
continuing-cyan
continuing-cyan13mo ago
you could use a search param but hide it using route masking
continuing-cyan
continuing-cyanOP13mo ago
Just found out about that and it's 100% my case
rival-black
rival-black13mo ago
Couldn't you use the actual state param?
continuing-cyan
continuing-cyanOP13mo 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?