URL State
Some state should live in the URL rather than React state. Search terms, filters, sorting, pagination, and selected tabs can often be represented as query parameters.
URL state is shareable, bookmarkable, and survives refreshes. This makes it particularly useful for search and catalog pages.
Search URL
/products?search=laptop&sort=price&page=2💡 The URL represents the current search state and can be shared with another user.
Key Takeaways
- Use URL parameters for shareable navigation state.
- URL state improves refresh and bookmarking behavior.
- Validate and normalize query parameters.