URL State, Search Params & Deep Linking

Filters, pagination, sort order, selected tabs, and search queries can often belong in the URL because users may bookmark, share, reload, or navigate back to them.

Treat query parameters as untrusted input. Parse and validate them rather than assuming they have the expected shape.

URL state also improves observability: support teams can reproduce a specific view from a link instead of asking users to describe hidden UI state.

Reading a query parameter
const params = new URLSearchParams(window.location.search);
const page = Math.max(1, Number(params.get("page") || 1));
const query = params.get("q") ?? "";
💡 Parsing URL state should include validation in production, especially when values influence API requests.
Key Takeaways
  • Put shareable/navigation-relevant state in the URL.
  • Validate query parameters.
  • Deep links improve reproducibility and user experience.