TanStackT
TanStack10mo ago
1 reply
uncertain-scarlet

Apply Middlewares globally

Is there a way to apply middlewares globally to every page?
I'm using this middleware: middlewares: [retainSearchParams(['rootValue'])]

It does exactly what I need, it retains certain query parameters across route changes. However, it only works when added to each page’s createFileRoute.

I’d like to apply it globally to all pages. Adding it to createRootRoute doesn’t seem to apply it to child routes.

Is there a way to apply such middleware globally, without having to add it manually to every single route?

Would appreciate any tips!
Was this page helpful?