DEV Community

Cover image for 11 Reasons why you should use NGXS as State Management in your Angular apps
Aliaksei Kuncevič for Ngxs

Posted on • Updated on

11 Reasons why you should use NGXS as State Management in your Angular apps

Developers tend to use state management solutions to solve some common problems developing modern single page applications. Building a modern web application using Angular you might not need to opt-in for a state management solution right away (it depends) but when the day comes NGXS is your best choice and here is why.

Why you should choose NGXS:

  1. Bulletproofed: NGXS was built back in Feb 2018. Since then, for many years, it has been chosen by many dev teams and companies as a state management solution for their Angular apps. Now there are 3.4+ million npm downloads to date!
  2. Backed by an awesome team: NGXS is an open source project maintained by a team of great software engineers from across the globe with a combined experience of 80+ years in software development.
  3. Angular way: NGXS written by Angular devs and for Angular devs. As a result, your store-related code uses a more familiar Angular approach that leverages dependency injection, decorators, etc.
  4. Great Features: There are many awesome features that NGXS offers: component communication, state operators, selectors and much more.
  5. Plugins: NGXS has a plugin system built-in - it is similar to Redux's meta reducers. You can use existing plugins to extend the functionality on top of your store or you can build your own plugin. Plugins that NGXS offering you: Logger, Devtools, Storage, Forms, Web Socket, Router and more!
  6. Less Boilerplate: NGXS was originally invented in response to the complexity and amount of boilerplate present in other state management solutions.
  7. Backwards Compatibility: NGXS team very strongly stands for backwards compatibility so by migrating to a new version of NGXS you can be assured that your codebase won’t require significant changes as part of the upgrade.
  8. Consistency and Maintainability: In practice it is much easier to maintain applications that build with the same fashion. When you use NGXS it gives your code a place to live and common patterns will emerge that will make for a much more maintainable codebase.
  9. Documentation: NGXS has a great documentation at NGXS.io in addition to that you can find some blog posts about NGXS on medium blog.
  10. Community: The NGXS community is strong, you can join NGXS slack channel if you have any questions or if you want to discuss anything or just to say hello.
  11. NGXS labs: NGXS labs is an organization on github - the place to test out the new ideas and to play around and experiment with new cool features and new plugins that are not yet under the main NGXS organisation. Here is the list of the additional features and plugins currently available at NGXS labs:

      - Data - NGXS Persistence API
      - Emitter - provides the opportunity to feel free from actions
      - Immer adapter - declarative state mutations
      - Dispatch decorator - provide separation of concern between the state management and the view
      - Select snapshot - decorator that allows to get a snapshot of the state
      - Async storage plugin - async Storage Plugin
      - Entity state - entity adapter
      - Actions executing - notifies if action is being executed
      - Attach action - attaching independent, pure and easy to test Action Handlers to NGXS State
      - Firestore plugin - firestore plugin for NGXS

So as you can see there are lots of reasons why you may want to consider NGXS as a state management solution for your Angular applications. To get started check up the documentation at ngxs.io and if you have any questions you can join the slack channel to discuss or just comment below.


My name is Aliaksei Kuncevič. I am teaching Angular and Web Technology. Helping dev teams to adopt Angular in the most efficient way. GDE, member of the NGXS Core Team.

I hope you find this content helpful and if so, please help to spread this article so more people can benefit from it.

If you want to learn more Angular tips and tricks join my newsletter at kuncevic.dev

If you want to know more about Angular subscribe for Angular Rocks podcast 🎙

Top comments (3)

Collapse
 
mflorence99 profile image
Mark Florence

Bingo -- NGXS rocks and I can't recommend @ngxs-labs/data highly enough! It is an excellent and well-designed simplification, over and above the awesome DX of NGXS itself.

Collapse
 
shantanugupta135 profile image
Shantanu gupta

Hello I am trying to implement ngxs-labs/entity-state, but got stuck at one point.
Could anyone help me here?

Collapse
 
kuncevic profile image
Aliaksei Kuncevič

Hey Shantanu, please join NGXS community slack where you can ask any questions 👉 tinyurl.com/ngxs-invite