TanStackT
TanStack3mo ago
3 replies
urgent-maroon

getRouteApi() Best Practices

Hey everyone, I am new to learning Router and have a potentially dumb question. In going through this example, I noticed the usage of getRouteApi('route/here') to access the router from outside the route definition. My concern here is if used incorrectly (outside of the route/here route tree), wouldn’t we see this not work/throw an error? I understand that this is more of a code quality/user error concern rather than a bug, similar to trying to access a React Context from outside of its Provider. Are there any guard rails you can set up to prevent this from happening?

I saw a few similar posts about getting the errors I am talking about, but wondering if there is a better guardrail than shouldThrow: false
Was this page helpful?