Search code examples
angularreduxstorengrx

Redux state management after refresh of page


I am using ngrx/store in my latest angular project. But I am struggling to find a better approach in maintaining the state after the refresh of any page. I store my access_token in the store so when I refresh It doesn't maintain the token and intercept send it without token. which eventually makes it a bad request.

What to do?? Any help is highly appreciated.

Regards, Fellow Software Engineer


Solution

  • You'll have to persist your state in for example the localStorage of the browser. You can do this by using meta reducers or in an effect.

    There is also a popular library called https://github.com/btroncone/ngrx-store-localstorage that does exact this thing.