Rewrite the whole thing using queryParams and make it more idiomatic

A couple things are missing like `replaceState` for query params, and might have some bugs here and there.
Nonetheless, enjoy! :)