Core 1.2 Migration
Migrate application code to the planned Nexus Core 1.2 release.
This rapid-iteration release contains breaking changes despite its minor version. Pin package versions; Core 1.x currently does not promise stable SemVer compatibility across minors. Published versions and their changelogs are unchanged.
Breaking release
Core 1.2 includes breaking changes despite the minor version. Upgrade participating packages and State hosts, clients, and relays together.
Package Versions
The planned release is Core 1.2, React 0.8, iframe 0.5, Chrome 0.5, and Node IPC 0.6. React and iframe require Core ~1.2.0. Chrome and Node IPC startup dialing needs Core 1.2; their existing declared Core ranges are unchanged. Verification covers the matching Core source, not a new test matrix of older Core releases. Testing has no independent API change in this release.
Native State Stores
- Replace
defineNexusStore(...)withcreateStoreToken<Store>(id, options?). Declare data and methods in one shared Store type. Validation belongs in token options; State APIs take that token directly, without a definition wrapper. - Pass the native Zustand creator and required options to
createNexusStore(token, creator, { snapshot, expose }), or bind an existing store withbindNexusStore(token, store, options). - Call local actions through
store.getState().action(). The returned store is Zustand’s original API;destroy()and[Symbol.dispose]belong to the binding. - Remote actions remain asynchronous but are no longer serialized or rolled back. A rejected action may already have mutated the source; do not blindly retry.
- Publication uses a fixed 200ms window by default, not an action-completion flush. Successful remote actions wait for their caller’s snapshot acknowledgement, not slow siblings. The default in-flight budget is 32 per subscription.
- The State service replaces dispatch and subscription IDs with one
subscribe(callback)channel carrying init, snapshots, and termination. Upgrade every participating State host, client, and relay together.
See State API for full examples. Ordinary RPC and virtual-port wire formats remain compatible; the State wire format does not.
React
- Import
useStorefromzustand, not@nexus-js/react. - Use
RemoteStore<Store>instead ofRemoteStoreWithInitialStateor separate state/actions type arguments. - Read acquisition from
{ store, pending, error, reconnect }. Acquisition error is not an existing handle’s disconnect status. - Replace
remote.statuswithuseStoreStatus(remote.store, selector)orScope.useStatus(selector). These return null without a handle and during SSR. - Select
status.typefor phase-only UI; selecting full status observes versions. - Replacement hides the old handle immediately and destroys it in effect cleanup. It no longer retains a stale handle while the replacement is pending.
- Select stable values or use Zustand’s
useShallow. Nexus no longer compensates for getters or selectors that produce fresh objects on every read.
See React State for acquisition and subscription examples.
Router And Startup
Custom adapter authors replace static VirtualPortRouter context operations with
new VirtualPortRouter(options) and instance safeListen, safeConnect, and
safeClose methods. Use the class itself as the instance type. Applications using
the iframe adapter do not need to construct the router themselves.
Optional endpoint.connectTo performs one-shot exact startup dialing after
listening. It does not infer a default target, block ready(), or add retries.
Node IPC applications using groups must move labels into application-owned
context metadata and use where predicates instead.
Errors
Await or catch ordinary proxy calls. Nexus no longer installs automatic rejection
observers for them; ignored failures follow the runtime’s unhandled-rejection
behavior. Raw State action callbacks retain Core errors. Use
safeInvokeStoreAction when a State-specific safe result is needed.