The NgRx SignalStore
@ngrx/signals' SignalStore — NgRx's own structure, rebuilt around signals instead of the classic actions-and-reducers pipeline.
The NgRx SignalStore
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- SignalStore replaces the classic action/reducer/effect pipeline's ceremony with a more direct API — state, computed values, and methods declared together — while keeping the same underlying discipline of centralized, traceable state changes.
- `withState`, `withComputed`, and `withMethods` are composable building blocks — a store is assembled from whichever of them it needs, rather than one fixed shape every store must follow.
- Choosing between classic NgRx and SignalStore isn't about one being strictly newer — classic NgRx's explicit action log still has real value for complex, cross-cutting state changes that benefit from that audit trail.
Keeping the discipline, cutting the ceremony
Classic NgRx’s actions-reducers-effects-selectors pipeline, from the previous
lesson, buys real guarantees — traceable state changes, pure state transitions,
a consistent shape across a large codebase. It also asks for a fair amount of
boilerplate to get there: an action creator, a reducer case, often an effect,
just to update one piece of state. @ngrx/signals’ SignalStore keeps the
underlying discipline — centralized, structured state, not ad-hoc mutation
scattered everywhere — while replacing the action/reducer indirection with an
API built directly around signals.
export const CounterStore = signalStore(
withState({ count: 0 }),
withComputed(({ count }) => ({
isEven: computed(() => count() % 2 === 0),
})),
withMethods((store) => ({
increment: () => patchState(store, { count: store.count() + 1 }),
})),
);
Composable building blocks, assembled per store
Notice the shape: signalStore(...) takes a list of feature functions —
withState, withComputed, withMethods — each contributing one piece.
withState declares the store’s initial state. withComputed derives values
from that state the same way computed() derives from a signal directly — in
fact, under the hood, that’s exactly what it’s doing. withMethods defines the
functions that change state, each one calling patchState(store, {...}) to
merge in an update, directly, with no separate action object and no reducer
matching against it elsewhere.
This composability is deliberate: a store only includes the features it actually needs, rather than every store being forced through one fixed action/reducer/effect shape whether or not a given piece of state genuinely needs that much machinery. A simple counter store, as above, needs none of classic NgRx’s ceremony to get real, structured, signal-based state.
When this replaces a plain service, and when it doesn’t
It’s worth being precise about where SignalStore sits relative to the
previous two lessons. Compared to a plain providedIn: 'root' service holding
signals (two lessons back), SignalStore adds conventions — a consistent shape
for state, computed values, and methods — that pay off once a feature’s state
gets complex enough that “just a service” starts feeling ad hoc. Compared to
classic NgRx, it trades some of that pattern’s explicit, named-action audit
trail for a flatter, more direct API — a real tradeoff, not a strict
improvement. A feature with genuinely complex, cross-cutting state interactions
that benefits from an explicit log of exactly what happened and when may still
be better served by classic NgRx’s more ceremonious but more traceable
structure; most features, in practice, don’t need that much ceremony, which is
exactly the gap SignalStore fills.
Features as reusable building blocks, not just the built-in three
withState/withComputed/withMethods are the core three, but signalStore
accepts any number of composed features, including ones you write yourself —
a reusable withEntities()-style feature handling a common collection
pattern (add/remove/update an item by id) can be shared across several
different stores that all happen to manage a list of something, rather than
each store reimplementing the same collection logic from scratch. This is the
part of SignalStore’s design that goes beyond simply “NgRx with less
boilerplate” — the feature system itself is meant to be extended, not just
consumed as a fixed set of three building blocks.
This lesson’s video is a talk directly from an NgRx core-team member, covering
SignalStore’s design and motivation firsthand — strong authority on exactly
this tradeoff. The linked “deeper” video is a longer, hands-on crash course
building a real feature with it if you want to see the API in extended use
rather than just explained.
Check yourself
In classic NgRx, updating state requires dispatching an action that a reducer handles. How does updating state typically look in a SignalStore instead?
Through a method defined with `withMethods`, calling `patchState(store, { ... })` directly — no action object to dispatch, no separate reducer function matching against it. The state change happens inline, in the method itself, which is a flatter structure than the classic action-then-reducer indirection.
Why might a team building a feature with genuinely complex, cross-cutting state logic still choose classic NgRx's actions-and-reducers over SignalStore?
Classic NgRx's explicit, named actions create a readable, centralized log of everything that's happened to the store — valuable for debugging complex interactions between many different parts of the state, and for tooling like time-travel debugging that relies on that action history. SignalStore's more direct, method-based API trades some of that explicit traceability for less ceremony, which is the right tradeoff for many features but not necessarily every one.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.