Access router context from within search middleware #7445
antoinerey
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Do you think it would be possible to read the router context from within search middleware?
I'm currently building a search system where filters must be accessible globally across the app for various purposes. However, these search filters may or may not be reflected into the URLs. For example, they must be synced with the URL on the search page, but not on the product page (because they're only used to pre-fill some form inputs).
To make the search filters accessible everywhere, I store them in the router context, and read them using
useRouteContext(). It works great. However, they're not available in search middleware, and thus I can't easily fill the missing search params when necessary.I currently achieve this using
beforeLoadbut it does not completely solve the problem. For example, links to the search page do not automatically define search filters in the query — which is something that search middleware solve super elegantly.Hence my question, would it be possible to have access to the router context within search middleware, or is there some technical issue to this?
I imagine the API to look like this:
Beta Was this translation helpful? Give feedback.
All reactions