Great post about using URL state more. And it's another reason why
@tan_stack router stands out from all the rest: It allows for true state management in the URL.
What do I mean with that?
1) It's type safe. The demo works great because it only has a string search field. But as soon as you have more complex filter criteria, you need to persist a full-blown json structure that's type-safe on read and write. You can try to bolt this on with another lib, but
@tan_stack router has this built-in.
2) It's optimized. Using the URL as a global state manager is great, but without fine-grained selectors, you have important state at the root of your component tree, distributed with basically react context. So every call to `useSearchParams` will re-render all subscribers, even if they are only interested in some parts of them.
@tan_stack router uses an external store and selectors for search & path params to avoid this. I don't think you can get this with any lib that builds on top of next/react-router.
📝 Got some Saturday reading for ya!
"How to control a React component with the URL"
One of those lessons you can never hear too many times — duplicate state is a stubborn problem that can be easy to miss.
Hope you enjoy!
buildui.com/posts/how-to-con…