TanStackT
TanStack3mo ago
14 replies
sacred-emerald

How to pass client data to loader/beforeLoad without URL params?

Hello!

Is there a way to pass data from the client to the router (loader or beforeLoad) without using URL params?

Right now my URLs look like this:
/org/$orgId/projects/...

The client should be able to switch between organizations using an org selector and each browser tab can work with a different org. In addition, upon tab reload orgId should be preserved.

I’d like to remove the /org/$orgId part from my URLs but I currently rely on it to preload data in some routes (server loaders). I tried with sessionStorage but obviously I cannot access it at server side. I tried router state but it is not kept on page reload.

Any ideas for cleaner ways to handle this scenario??

Thank you!
Was this page helpful?