Search code examples
angularreduxngrx

Angular4/ngRx: Is it good idea to keep auth state in ngRx store?


In my application, I was wondering if I can use the ngRx store to keep the JWT token(auth token)?

I understand that once the browser refreshes, the store will be reset, but I can workaround this issue by keeping the app state itself in local storage.

What I am trying to find out(and didin't find any results for) is how the ngRx store behaves for multiple users? Will each of them get their own store? Or will they use common app level store? If latter is the case then it would be a very bad design to keep auth state in ngRx store.

PS: I am new to angular.


Solution

  • Generally not,

    You should keep JWT token in localStorage, and have proper Guard's which will check if jwt is expired ( redirect to login ) or not.