Should filter state go in the URL in React?
Yes. Filters, search, and pagination belong in query parameters. They are part of the URL and persist across reloads, which is the right behavior, and they make filter states shareable.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in How to Pass Data Between Screens in a React App
Use URL parameters for identity, query parameters for filters, Link state for one-time transitions, Context or a store for widely-shared data, and a server fetch by id for large data. The question of whether data should survive a reload dictates the pattern.
For data that identifies a screen, like /user/:id. URL parameters make the screen shareable and bookmarkable, and they survive reloads, which is the right behavior for identity.
For small, one-time data between navigations, like a success message after a redirect. It does not survive a reload, so only use it for non-essential transitions, not for data the destination screen depends on.
Still have questions?
Browse all our FAQs or reach out to our support team
