unstale

npm / xstate

xstate

What changed in xstate 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

131 breaking52 new APIs and options11 behavior and defaults19 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

xstate 5213 changes

Breaking changes 131

  • Targeting a history state that is a direct child of an unvisited parallel state with no default target now enters the parallel state's initial configuration instead of doing nothing.

    5.32.4release notes

  • Action, actor, delay, and guard arguments are consolidated into a single object argument.

    5.0.0release notes

  • Builtin action creators such as assign and sendTo now return functions; users should pass around their returned values without relying on their shape.

    5.0.0release notes

  • Restored state no longer contains actions, which are assumed to have already run; restoration does not replay them.

    5.0.0release notes

  • Actions are no longer called with state.

    5.0.0release notes

  • Activities were removed; implement them as invoked callback services instead.

    5.0.0release notes

  • The actor.batch([...]) method is removed; loop over events and send them individually.

    5.0.0upgrade guide

  • Use actor.getSnapshot() to read the current snapshot; subscribing after start no longer immediately emits it.

    5.0.0upgrade guide

  • actor.onTransition(...) is removed; use actor.subscribe(...).

    5.0.0upgrade guiderelease notes

  • actor.send() no longer accepts string event types; send an event object instead.

    5.0.0upgrade guide

  • Actor status is no longer publicly available as a property.

    5.0.0release notes

  • Subscribing after an actor has started no longer immediately emits the current snapshot.

    5.0.0upgrade guiderelease notes

  • The onEvent, onSend, and onChange handlers were removed; use onTransition or subscribe.

    5.0.0release notes

  • Sending requires an event object, and the separate payload argument is no longer supported.

    5.0.0release notes

  • Sending a string event now throws a proper error message.

    5.0.0release notes

  • The method no longer returns the next state and is now a void, fire-and-forget function.

    5.0.0release notes

  • The redundant sender method was removed; use actorRef.send instead.

    5.0.0release notes

  • The services property has been renamed to actors.

    5.0.0upgrade guiderelease notes

  • machine.transition and machine.getInitialState now require an actorScope argument.

    5.0.0release notes

  • Delayed transitions can no longer be defined using an array; only the object variant is supported.

    5.0.0release notes

  • Internal after event types changed from the parenthesized form to xstate.after.<delay>.<state-id>.

    5.0.0release notes

  • Eventless transitions must use the always property; an empty string can no longer define them.

    5.0.0upgrade guiderelease notes

  • Always transitions are not selected when the preceding transition does not change machine state, reducing the risk of infinite loops.

    5.0.0release notes

  • Transitions can no longer be configured using arrays; only regular object-based configs are supported.

    5.0.0release notes

  • Assign actions execute in definition order, and later actions reading context see intermediate values; define assigns first to retain the previous behavior.

    5.0.0release notes

  • Executing assign when context is undefined now throws an error instead of issuing a warning.

    5.0.0release notes

  • The autoForward property on invoke configs is removed; send events explicitly instead.

    5.0.0upgrade guiderelease notes

  • Child state nodes are always re-entered when targeted by transitions defined on compound state nodes; stateIn can prevent undesirable re-entry.

    5.0.0upgrade guide

  • When context types are specified in machine config, the context property is required; context is restricted to an object, and undefined defaults to an empty object.

    5.0.0release notes

  • Machine factories no longer accept context as a third argument, and machine config context no longer accepts a function.

    5.0.0release notes

  • Pass a snapshot in createActor's options to restore actor state; actor.start() no longer accepts a state argument.

    5.0.0upgrade guiderelease notes

  • The state option was renamed to snapshot.

    5.0.0release notes

  • The Machine(config) function is now called createMachine(config).

    5.0.0upgrade guiderelease notes

  • The function was removed in favor of strong types in machine configuration.

    5.0.0release notes

  • The actor options property deferEvents was removed.

    5.0.0release notes

  • Use enqueueActions() instead of the removed pure() and choose() methods.

    5.0.0upgrade guiderelease notes

  • Machine error events are thrown if the actor has no registered error listener.

    5.0.0release notes

  • The escalate action creator is removed; actions can throw errors that propagate and can be handled with an onError transition.

    5.0.0upgrade guiderelease notes

  • _event was removed from all APIs and types.

    5.0.0release notes

  • Error events now carry error data in event.error instead of event.data.

    5.0.0release notes

  • The interpreter execute option was removed; the interpreter executes actions immediately according to SCXML semantics.

    5.0.0release notes

  • Exit actions are no longer called when a machine is stopped externally, but still run when it reaches its final state.

    5.0.0release notes

  • The transition property external was renamed to reenter.

    5.0.0release notes

  • Callback actors may return only cleanup functions or undefined; returning promises no longer works.

    5.0.0release notes

  • sendBack and receive are now merged with the other properties passed to the callback logic creator.

    5.0.0release notes

  • fromReducer was renamed to fromTransition.

    5.0.0release notes

  • The method was renamed to getPersistedSnapshot.

    5.0.0release notes

  • The cond transition property is now called guard.

    5.0.0upgrade guiderelease notes

  • Guards now receive a single object argument rather than separate context and event arguments.

    5.0.0release notes

  • Guard objects use the guard property, and guard parameters belong in the params property.

    5.0.0release notes

  • Implementation functions now receive one object argument containing context, event, and other properties.

    5.0.0upgrade guide

  • The in transition property is removed; use guard: stateIn(...) instead.

    5.0.0upgrade guiderelease notes

  • An error is thrown when a compound state node does not specify an initial state.

    5.0.0release notes

  • Use input to provide data to an actor and derive machine context from it.

    5.0.0upgrade guide

  • Use the inspection API to observe events.

    5.0.0upgrade guide

  • The off method was removed.

    5.0.0release notes

  • The method was removed; use interpreter.subscribe with an error observer.

    5.0.0release notes

  • Use actorRef.subscribe with a complete observer instead.

    5.0.0release notes

  • The invoke.data property is removed; use invoke.input to provide context to invoked actors.

    5.0.0upgrade guide

  • Use invoke.input to provide context to invoked actors.

    5.0.0upgrade guide

  • Use actor logic creators as invoke.src instead of functions.

    5.0.0upgrade guide

  • A string value can no longer be passed directly to invoke; use the object form with src.

    5.0.0release notes

  • Replaces isState and isStateConfig; AnyState is deprecated in favor of AnyMachineSnapshot.

    5.0.0release notes

  • Compound string state values are no longer accepted; use the state value representation instead.

    5.0.0release notes

  • Invalid state values, including values with nonexistent state regions, are no longer handled; rehydrated data must be migrated when the machine schema changes.

    5.0.0release notes

  • The machine property formerly named machine.options is now machine.implementations.

    5.0.0release notes

  • machine.withConfig() has been renamed to machine.provide().

    5.0.0upgrade guiderelease notes

  • machine.transition(…) now requires an actor scope for its third argument.

    5.0.0upgrade guide

  • The third context argument and direct state-value inputs were removed; pass a resolved MachineSnapshot containing context instead.

    5.0.0release notes

  • Directly overriding context with machine.withContext(...) is no longer supported; use input instead.

    5.0.0upgrade guide

  • The machineConfig.schema property is renamed to machineConfig.types.

    5.0.0upgrade guide

  • machineConfig.tsTypes has been renamed and moved to machineConfig.types.typegen.

    5.0.0upgrade guide

  • The nextEvents property was removed.

    5.0.0release notes

  • The utility function was removed.

    5.0.0release notes

  • The matchState helper function was removed.

    5.0.0release notes

  • The Interpreter method was removed; use State#can to check whether sending an event would lead to a state change.

    5.0.0release notes

  • The previously deprecated configuration property was removed.

    5.0.0release notes

  • The machine's final output is now specified on the machine config's output property rather than on the final state.

    5.0.0release notesupgrade guide

  • The package exports field limits imports to files that are part of the public API.

    5.0.0release notes

  • Action and guard object properties other than type must be nested under params and are passed as the implementation's second argument.

    5.0.0upgrade guiderelease notes

  • The flag is no longer required because actions are ordered predictably by default; assign actions run in definition order.

    5.0.0upgrade guide

  • Dynamic input and output must use a function rather than an object with property mappers.

    5.0.0upgrade guide

  • Use raise(...) to send events to self.

    5.0.0upgrade guide

  • Delayed event IDs are no longer derived from event types; provide an explicit ID when cancelling a delayed raised event.

    5.0.0release notes

  • Atomic and parallel states are no longer reentered when the target does not escape them; set reenter: true to retain reentry.

    5.0.0release notes

  • The send(...) action creator is removed; use raise(...) for self-directed events or sendTo(...) for other actors.

    5.0.0upgrade guiderelease notes

  • The batch method was removed.

    5.0.0release notes

  • Invoked and spawned actors are no longer available on service.children; access them from state.children.

    5.0.0release notes

  • The send(type, payload) call shape is no longer supported.

    5.0.0release notes

  • The snapshot.done property is removed; use snapshot.status === 'done', which is available to all actors.

    5.0.0upgrade guide

  • EmittedFrom was renamed to SnapshotFrom.

    5.0.0release notes

  • The imported spawn() function is removed; use spawnChild(...) or the assigner argument's spawn method.

    5.0.0upgrade guide

  • spawn is no longer imported from xstate; obtain it from assign metadata, and actors from implementations can be spawned by name.

    5.0.0release notes

  • Use the spawnChild(...) action creator to create child actors.

    5.0.0upgrade guide

  • The State class was replaced by MachineSnapshot objects, so instanceof State checks no longer work.

    5.0.0release notes

  • The property was removed because actions are transition side effects and are not meant to persist.

    5.0.0release notes

  • Removed State['changed']; matching transitions create a new State instance, while no matching transitions return the current state.

    5.0.0release notes

  • The State event type was removed.

    5.0.0release notes

  • The internal queue property was removed.

    5.0.0release notes

  • The state.configuration property has been renamed to state._nodes.

    5.0.0upgrade guide

  • The state property was removed; obtain the session ID from actor.sessionId.

    5.0.0release notes

  • state.can() no longer accepts string event types; pass an event object instead.

    5.0.0upgrade guide

  • The children property now maps invoked actor IDs to ActorRef instances; actor interfaces use opaque ActorRef references.

    5.0.0release notes

  • The property was renamed to state.nodes.

    5.0.0release notes

  • The property is removed because events are not part of state unless explicitly added to context; use the inspection API to observe events.

    5.0.0upgrade guiderelease notes

  • The method was removed; use StateMachine#resolveState instead.

    5.0.0release notes

  • The state.meta property has been renamed to state.getMeta().

    5.0.0upgrade guiderelease notes

  • The state.history property is removed; maintain previous snapshots through actor.subscribe(...).

    5.0.0upgrade guiderelease notes

  • Its shape now maps state node IDs to historic descendant state nodes, following the SCXML algorithm; it is considered internal.

    5.0.0release notes

  • The state.nextEvents property is removed because it is not a completely safe or reliable way to determine sendable events.

    5.0.0upgrade guide

  • The state.toStrings() method has been removed.

    5.0.0upgrade guiderelease notes

  • The transitions property was removed from State.

    5.0.0release notes

  • Use the stateIn guard to validate state transitions instead of the removed in transition property.

    5.0.0upgrade guide

  • The isTransient property was removed from StateNode.

    5.0.0release notes

  • StateSchema was removed from all generic type signatures.

    5.0.0release notes

  • The action creator was renamed to stopChild to clarify that a parent can stop only child actors.

    5.0.0release notes

  • Strict mode is removed; use a wildcard transition to throw on unhandled events.

    5.0.0upgrade guiderelease notes

  • The sync option was removed from invoke and spawn.

    5.0.0release notes

  • Transitions are internal by default rather than external; use reenter: true when the previous re-entry behavior is needed.

    5.0.0upgrade guide

  • Transitions are internal by default; set external: true to reenter the source state when the target lies within it.

    5.0.0release notes

  • The machine schema property is now types, and tsTypes is now types.typegen.

    5.0.0release notes

  • XState v5 requires TypeScript 5.0 or greater; strictNullChecks and skipLibCheck are recommended.

    5.0.0upgrade guide

  • Typestate typings were removed because manually specified state value and context types can describe impossible states.

    5.0.0release notes

  • useActor(logic) now accepts actor logic instead of an existing ActorRef; use useSelector and actor.send with an existing ActorRef.

    5.0.0upgrade guide

  • React hooks no longer accept lazy machine creators or implementations as a second argument; pass machine.provide(...) as the first argument.

    5.0.0upgrade guide

  • The Vue hook returns snapshot instead of state, and actor instead of service.

    5.0.0upgrade guide

  • The default timeout is now Infinity instead of 10 seconds.

    5.0.0release notes

  • Automatically generated events now use the xstate. prefix, with event names such as done.invoke.* changed to xstate.done.actor.*.

    5.0.0release notes

  • Redux dev tools support is no longer the default and can be included from this module.

    5.0.0release notes

  • Done events are now generated recursively for all parallel states on the ancestors path.

    5.0.0release notes

  • The listed helpers and actor creators can now be imported from xstate; the send action export was removed.

    5.0.0release notes

New APIs and options 52

  • Add types.transitionMeta to type transition metadata separately from state metadata; when omitted, types.meta continues to apply to both.

    5.33.0release notes

  • Exports InspectedTransitionEvent from xstate, making it available to developers.

    5.32.0release notes

  • Adds mapState(snapshot, mapper) to map a snapshot to values based on active states.

    5.31.0release notes

  • Adds an option to configure the maximum number of microsteps allowed before throwing an infinite loop error; it defaults to Infinity.

    5.31.0release notes

  • Adds an option to xstate/graph traversal helpers and createTestModel to control which events are explored from each state, enabling enabled-only traversal.

    5.30.0release notes

  • Adds a method that derives a Readable from an actor snapshot, with subscribe and synchronous get access; subscriptions emit only when the selected value changes.

    5.29.0release notes

  • States with route: {} and an explicit id can be navigated to from anywhere using an xstate.route event; routes can also use guards for conditional navigation.

    5.28.0release notes

  • Returns an array of snapshot-and-actions tuples for each microstep in the initial transition.

    5.27.0release notes

  • Returns an array of snapshot-and-actions tuples for each microstep in a transition.

    5.27.0release notes

  • Adds a utility that returns all transitions available from the current state.

    5.26.0release notes

  • Adds a method to incrementally extend machine setup configurations with actions, guards, and delays that can reference base definitions and support chaining.

    5.24.0release notes

  • Action implementations can access action parameters directly as their second argument.

    5.0.0release notes

  • XState v5 adds the ability to create actor systems.

    5.0.0upgrade guide

  • Interop observable symbols were added so actor refs are compatible with libraries such as RxJS.

    5.0.0release notes

  • Higher-level guards now support composing guards with and, or, and not.

    5.0.0release notes

  • The cancel action now supports expressions.

    5.0.0release notes

  • Wildcard transitions can handle unhandled events, including throwing when an event is unknown.

    5.0.0upgrade guide

  • The second argument accepts input data, which is passed in the xstate.init event.

    5.0.0release notes

  • The inspect option lets applications observe actor creation, events sent between actors, and emitted snapshots.

    5.0.0release notes

  • Creates an actor that does nothing, useful for testing and integrations that require an actor when one may be absent.

    5.0.0release notes

  • XState v5 adds deep persistence for invoked and spawned actors.

    5.0.0upgrade guide

  • The new action creator enqueues actions for execution and offers an alternative to pure and choose.

    5.0.0release notes

  • fromCallback is an available actor logic creator.

    5.0.0upgrade guide

  • fromEventObservable is an available actor logic creator.

    5.0.0upgrade guide

  • fromObservable is an available actor logic creator.

    5.0.0upgrade guide

  • fromPromise is an available actor logic creator.

    5.0.0upgrade guide

  • fromTransition is an available actor logic creator.

    5.0.0upgrade guide

  • Use getNextSnapshot(...) to get the next snapshot from actor logic based on a current snapshot and event.

    5.0.0upgrade guide

  • Guard implementations can access guard parameters directly as their second argument.

    5.0.0release notes

  • XState v5 adds higher-level guards.

    5.0.0upgrade guide

  • XState v5 adds an inspect API.

    5.0.0upgrade guide

  • Returns the intermediate MachineSnapshot for a single microstep, without transient transitions or raised events, for debugging.

    5.0.0release notes

  • Invoke configs can define a transition to take when an invoked actor's snapshot updates.

    5.0.0release notes

  • The onSnapshot transition object is supported for invoked machines, observables, promises, and transition functions.

    5.0.0release notes

  • XState v5 adds partial event descriptors, also described as partial wildcards.

    5.0.0upgrade guiderelease notes

  • Use reenter: true instead of internal: false to specify external transitions.

    5.0.0upgrade guide

  • The self actor reference is available in all action metadata.

    5.0.0release notes

  • Actor logic creators now receive self in their arguments.

    5.0.0release notes

  • The setup API lets developers specify types and strongly typed state values.

    5.0.0upgrade guide

  • setup().createMachine() configures actor, action, guard, and delay implementations for a machine.

    5.0.0release notes

  • The stateIn guard supports checking a combination of an ID and a path.

    5.0.0release notes

  • Actors belong to implicitly created systems that allow actors to be registered and referenced using systemId.

    5.0.0release notes

  • Actor logic creator functions now receive system in their arguments.

    5.0.0release notes

  • Machines can now declare action types, allowing action configurations to be checked for required parameters and unknown action names.

    5.0.0release notes

  • Actor source names, IDs, and logic can now be specified in machine types for stronger typing of invoke configuration and output.

    5.0.0release notes

  • Child IDs can be typed with types.children when using setup.

    5.0.0release notes

  • Machines can now specify delay types.

    5.0.0release notes

  • Machines can now declare their guard types.

    5.0.0release notes

  • Machine input types can now be declared and are strongly typed in the context initializer and actor input.

    5.0.0release notes

  • Machines can now specify output types to strongly type snapshot.output.

    5.0.0release notes

  • Machines can now define strict tag types.

    5.0.0release notes

  • The @xstate/react useInterpret() hook has been renamed to useActorRef().

    5.0.0upgrade guide

Behavior and default changes 11

  • assertEvent now supports partial descriptors, allowing checks for events whose type starts with a given prefix.

    5.25.0release notes

  • Action and guard parameters can now be resolved dynamically.

    5.0.0release notes

  • Snapshots now share status, output, error, and context properties, so actor results are read from a consistent snapshot shape.

    5.0.0release notes

  • The interpret() function has been renamed to createActor().

    5.0.0upgrade guiderelease notes

  • Spawned actors with a referenced, non-inline source can now be deeply persisted and restored.

    5.0.0release notes

  • A state node's initial configuration can include executable content such as actions.

    5.0.0release notes

  • Partial event descriptors now infer event types safely, including the matching event variants and their fields.

    5.0.0release notes

  • State values and snapshot.matches() arguments are now strongly typed when using the setup API.

    5.0.0release notes

  • Use snapshot.status === 'done' to check completion; status is available to all actors.

    5.0.0upgrade guide

  • Spawn arguments are now strongly typed based on actor types.

    5.0.0release notes

  • Actors can now be spawned directly outside assign action creators.

    5.0.0release notes

Fixes and other changes 19

  • assertEvent now narrows generic event parameters and events whose type is a union of literals, while still rejecting invalid event descriptors.

    5.33.4release notes

  • Partial wildcard descriptors now preserve the bare prefix event in narrowed types, matching runtime behavior; this also applies to event types inferred for partial wildcard transitions.

    5.33.4release notes

  • When an unhandled error from an invoked actor causes a machine to error, remaining invoked and spawned actors are stopped and their cleanup functions called before the machine settles in the error state.

    5.33.3release notes

  • Generic history values, snapshot nodes, and directed graph results now accept arbitrary state and transition metadata consistently, avoiding unsafe-type warnings when inspecting machines through generic APIs.

    5.33.2release notes

  • AnyStateNode, AnyStateNodeDefinition, and AnyTransitionDefinition now widen their metadata parameters to match nodes of an AnyStateMachine, avoiding unsafe-argument and unsafe-return reports.

    5.33.1release notes

  • Machine snapshots retain their machine-specific methods when initialization fails, keeping methods such as snapshot.matches(...) available on error snapshots.

    5.32.6release notes

  • Sending an event containing unserializable data to a stopped actor no longer throws; the development-only warning is emitted safely.

    5.32.5release notes

  • Fixes initialTransition and transition throwing a duplicate system ID error when a machine contains an invoke with a systemId.

    5.32.3release notes

  • When guards on an exact event descriptor all fail, matching wildcard descriptor transitions are now tried as fallback.

    5.32.2release notes

  • Fixes children snapshot union pollution for typed invoke.

    5.32.1release notes

  • Named guards registered with setup({ guards }) are now resolved for route.guard.

    5.31.1release notes

  • Types are exported so setup() declaration emit works.

    5.28.0release notes

  • Fixes cleanup of systemId for nested children when stopChild is used.

    5.25.1release notes

  • Fixes a bug in Cordova when iterating an empty Map.

    5.25.0release notes

  • Actors with the same ID are correctly reinstantiated when stopped and then invoked or spawned again in the same microstep.

    5.0.0release notes

  • Errors thrown in an observer no longer crash actors; they are passed to the observer's error handler, or thrown with a clear stack if none is provided.

    5.0.0release notes

  • Fixed a runtime crash for machines whose root state's type is final.

    5.0.0release notes

  • Inline actions are correctly executed when an equally named action is provided through the implementations argument.

    5.0.0release notes

  • Errors caught during actor execution are consistently included in snapshot.error and reported to the closest error listener.

    5.0.0release notes