Open any product page with filters, change the URL to ?page=abc&sort=cheapest , and press Enter.
Most apps do one of three things. They crash, they show an empty list, or they quietly treat "abc" as a page number and send it to the API. All three happen for the same reason: the app treats the URL as trusted data, when it's really user input.
This post shows how TanStack Start handles that. By the end you'll have a filter page where:
bad or missing values fall back to defaults instead of breaking the page,
your component reads page as a number and sort as one of three strings, not string | undefined ,
a <Link> that passes the wrong type fails at compile time,
the loader refetches only when the filters it depends on change.
It's for React devs who know the basics of TanStack Start (file routes, loaders). If you don't, our free TanStack Start course on YouTube covers them.
Why the URL is the right place for filters
Filters, sort order and pagination are state.…