npm / @ai-sdk/react
@ai-sdk/react
What changed in @ai-sdk/react 2 to 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
6 breaking3 new APIs and options1 performance3 behavior and defaults18 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/react 430 changes
Breaking changes 6
addToolOutput now rejects continuous sessions.
Removes the deferred managed Responses coordinator and the autoContinueTools option.
Backend usage state is removed from the realtime runtime.
Live tool-result aliases are removed.
Realtime configuration now requires explicitly selecting relay transport mode.
sendTextMessage now rejects continuous sessions.
New APIs and options 3
Applications exchange WebRTC SDP through an application endpoint using api.session.
Experimental client-delegated Live conversations can use browser-direct WebRTC alongside WebSockets.
Adds realtime WebSocket sessions with lifecycle management, transcripts, context append, reversible capture, acknowledgements, and continuous PCM playback.
Performance 1
Unused realtime runtime code can now be tree-shaken, potentially reducing application bundle size.
Behavior and default changes 3
Default chat IDs are generated on first access, allowing useChat() to prerender without reading a random value when the ID is unused during rendering.
Live continuous sessions enforce 128 KiB frame and combined buffered-send budgets using actual encoded wire bytes.
Adds WebSocket relay support with shared session state, capture controls, bounded playback, graceful close, and application-handled Live delegation.
Fixes and other changes 17
Preserves replay semantics when using custom chat transports.
Prevents a second resume request on mount when an already submitted or streaming chat remounts with a shared Chat instance.
Prevents stale object streams from overwriting newer results.
Streamed chat updates no longer starve navigation transitions.
Automatic stream resumption is deduplicated for shared Chat instances, preventing duplicate resumption behavior.
Replacement completion requests remain loading and cancellable when an earlier request settles.
Prevents stale throttled completion updates from overwriting a newer request.
Preserves Headers instances in useCompletion requests.
Handles rejected asynchronous onFinish callbacks.
Preserves active cancellation state during overlapping requests.
Keeps useObject cleared when an initial value is configured.
Realtime session ownership and callbacks publish only after React commits, preserving connected sessions across abandoned renders and unmounting controls safely.
Omitted onToolCall remains undefined, preserving missing-tool-handler diagnostics; defined handlers returning undefined still support manual tool output.
maxPlaybackBufferSeconds is supported only for continuous PCM sessions.
Chats are aborted when their useChat id changes during a stream.
Fallback errors are surfaced for empty HTTP response bodies.
Preserves the generated useObject value when the API URL changes.
@ai-sdk/react 21 changes
Fixes and other changes 1
Nullish useChat IDs are treated like omitted IDs, preventing chat instance recreation on every render.