Skip to content

Pass data between routes #1342

Answered by SeanCassiere
rajivharris asked this question in Q&A
Discussion options

You must be logged in to vote

The concept of params relates to path parameters. For example, in this path /posts/$postId, the param is the $postId. As such, by default, all the path parameters are string.
So this navigation would look like:

navigate({ to: '/posts/$postId', params: { postId: '123' } });

What you are looking for might be similar to the browser native window.history.pushState.
Tanstack Router does allow you to pass data between routes during navigation using the state field.

🚧 Tanstack Router currently does not provide any type-safety at runtime for this because of the challenges in data serialization for this magic field.

If you want to use it, you'll need to register the types for this HistoryState u…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rajivharris
Comment options

Answer selected by rajivharris
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants