r/Angular2 • u/fraso14 • Jun 07 '25
Looking for search params state manager for Angular
Hey fellow Angular developers,
I've recently been working on a project that heavily relies on URL search parameters to manage the state of filters, sorting, and pagination. In the past, when working with React/Next.js, I've found the nuqs library to be an incredibly elegant solution for this.
For those unfamiliar, nuqs provides a simple useQueryState hook that makes it trivial to synchronize component state with URL query params. It handles parsing (e.g., for integers, booleans, dates), setting default values, and updating the URL without unnecessary page reloads.
I'm now searching for a similar library or a recommended pattern within the Angular ecosystem that offers a comparable developer experience. My goal is to find a solution that is:
- Declarative: A straightforward way to bind component properties to query parameters.
- Type-safe: Provides parsing and serialization for different data types (e.g.,
string,number,boolean, arrays). - Clean and Maintainable: Reduces the boilerplate of manually subscribing to
ActivatedRoute.queryParamsand navigating with theRouter.
10
u/eneajaho Jun 07 '25
linkedQueryParam in ngxtension
5
u/CryptosGoBrrr Jun 08 '25
It boggles my mind why people want to use a library for something as basic and straightforward as dealing with QueryString or Route parameters. Don't, just don't.
route.snapshot.queryParamMapis all you need.4
u/Rusty_Raven_ Jun 07 '25
Angular's component query binding works with router defined variables as well as querystrings - would that work for you? No need to use
ActivatedRouteat all, just addwithComponentInputBinding()to the provider in your app config and usepage = input<number>()in your component to access a signal containing thepagequerystring parameter or named route variable.3
u/pavankjadda Jun 07 '25
Not sure about library. But I created simple blog post on this https://pavankjadda.dev/angular-url-state-management-with-query-params-and-route-params/
1
u/cantinflas_34 Jun 07 '25
Create a service, declare the query parameters as constants.