T
TanStack7mo ago
harsh-harlequin

Equivalent to React Router `handle`?

Hi everyone, I'm currently transitioning a project from RR to Tanstack Router and I haven't exactly found an equivalent for the route handle concept (https://reactrouter.com/start/framework/route-module#handle). Baiscally, I need a way to return some component or value from a route and be able to retrieve it further up the tree using useMatches. I thought context should help (as I can see the output of useMatches has a context object) but I can't figure out how to pass a value from within a root. Any thoughts?
2 Replies
adverse-sapphire
adverse-sapphire7mo ago
Static Route Data | TanStack Router React Docs
When creating routes, you can optionally specify a staticData property in the route's options. This object can literally contain anything you want as long as it's synchronously available when you crea...
harsh-harlequin
harsh-harlequinOP7mo ago
Yes!!!! That's the one, thank you

Did you find this page helpful?