Authentication state, persisting state and browser storage
Learn Authentication state, persisting state and browser storage (Module 15 · State Management, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Authentication state and saving state • Authentication state = who is logged in: the user, their roles and the token. It is a classic shared state: put it in one AuthStore that guards, interceptors and menus use. • Persisting state means keeping it after a refresh by saving to the browser: LocalStorage (stays until cleared, shared across tabs) or SessionStorage (until the tab closes). • Both store strings only: use JSON.stringify / JSON.parse .
More lessons in Module 15 · State Management
- Module 15 overview and checklist
- State fundamentals: local, shared, service, RxJS and Signals state
- Immutable updates, normalization, derived, loading and error state
- NgRx fundamentals: Store, actions, reducers, selectors
- NgRx effects, entities, feature state and DevTools
- NgRx Signal Store
- State management testing and choosing an approach