TanStack AI 1.0 Migration: Upgrade from 0.x Step by Step

A TanStack AI 1.0 migration is mostly renames, not new concepts: run the official codemod, move every stable @tanstack/ai* package to 1.0 in one step, then fix what the type checker reports. The changes that break apps are threadId (now required on client and server), body becoming forwardedProps, tool approvals moving to interrupts, and the removal of the prebuilt *-ui chat components. Migrate any saved chats before you deploy, because a clean type check does not convert stored data.

Written 2026-10-29. Package names, commands and API names were checked against the TanStack AI 1.0 announcement (October 23, 2026), the official v1 upgrade guide and the npm registry on that date. TanStack AI moves fast, so re-check the linked docs before a production upgrade.

What changed in TanStack AI 1.0

TanStack released TanStack AI 1.0 on October 23, 2026. All 76 packages went stable together, and npm now lists 1.0.0 as the latest tag for @tanstack/ai. The team says 1.0 "has no new concepts": every API that 0.x had marked deprecated was removed, and each replacement already shipped in a 0.x release.

That matters for planning. If you kept your 0.x app free of deprecation warnings, most of the work is mechanical. If you ignored them, expect a longer list of type errors.

AreaAlpha (Dec 2025)1.0 (Oct 2026)
Provider adapters423, plus openaiCompatible
UI frameworksReact, Solid, vanilla JS9, including Vue, Svelte, Angular, Preact
Coding agentsNoneClaude Code, Codex, OpenCode, Grok Build, any ACP agent
Sandbox providersNone11

The one big exception is the new agent harness. It is still experimental and stays on 0.x versions, so do not bump it with the rest.

TanStack AI 1.0 migration package map showing stable packages to upgrade, experimental harness packages to keep on 0.x, and removed UI packages
Which TanStack AI packages to upgrade, keep or remove
Package groupExamplesWhat to do
Stable@tanstack/ai, @tanstack/ai-react, @tanstack/ai-openai, @tanstack/ai-persistence, @tanstack/ai-mcp, @tanstack/ai-acpUpgrade all to 1.0 together
Experimental@tanstack/ai-harness, @tanstack/ai-harness-cli, @tanstack/ai-skills/harness, @tanstack/ai-acp/agentStay on 0.x
Removed@tanstack/ai-react-ui, @tanstack/ai-solid-ui, @tanstack/ai-vue-uiUninstall, rebuild UI with createChatHook

Before you start the TanStack AI 1.0 migration

Do these three things first. They keep the upgrade reversible.

  1. Work on a branch and commit your lockfile. If the upgrade goes badly, you can roll back with one git checkout.
  2. List every TanStack AI package your project uses, so none stays behind on 0.x.
  3. Check for stored data. Do you persist chats, runs or artifacts in a database, localStorage or a sandbox? If yes, read the saved-data section below before deploying.
git checkout -b tanstack-ai-1-0
npm ls --depth=0 | grep "@tanstack/ai"

A 1.0 client needs a 1.0 server. If your frontend and backend live in different repos or deploy separately, plan to ship both at the same time. A half-upgraded stack is the most likely cause of broken streams.

If you are also moving runtimes, finish that first and upgrade one thing at a time. Our Node.js 26 LTS upgrade checklist covers the runtime side.

Step 1: Run the TanStack AI codemod

The official codemod handles the most common renames. Preview it first with --dry --print, then run it for real:

Preview (nothing is written):

npx jscodeshift --dry --print \
  --parser=tsx \
  -t https://raw.githubusercontent.com/TanStack/ai/main/codemods/ag-ui-compliance/transform.ts \
  "src/**/*.{ts,tsx}"

Apply the changes:

npx jscodeshift \
  --parser=tsx \
  -t https://raw.githubusercontent.com/TanStack/ai/main/codemods/ag-ui-compliance/transform.ts \
  "src/**/*.{ts,tsx}"

What the codemod changes:

  • body → forwardedProps in useChat, new ChatClient and client.updateOptions
  • Svelte updateBody → updateForwardedProps
  • conversationId → threadId in chat() (the key only, not the value)

What it does not change, so you must fix these by hand:

  • reads of body.data on the server
  • the value you pass to threadId
  • body inside createChatHook, useAppChat overrides and Angular injectChat
  • files that call the hooks through a barrel re-export

Running a remote transform script executes code from GitHub on your machine. Read the transform file first if your security policy requires it, or pin it to a specific commit instead of main.

Step 2: Upgrade all stable packages to 1.0 together

The upgrade guide does not give an install command, so use your package manager's normal syntax. Upgrade everything stable in one command, and remove the three UI packages:

With npm:

npm install @tanstack/ai@^1 @tanstack/ai-react@^1 @tanstack/ai-openai@^1
npm uninstall @tanstack/ai-react-ui

With pnpm:

pnpm add @tanstack/ai@^1 @tanstack/ai-react@^1 @tanstack/ai-openai@^1
pnpm remove @tanstack/ai-react-ui

Swap in your own framework and provider packages, for example @tanstack/ai-vue or @tanstack/ai-anthropic. Leave @tanstack/ai-harness and @tanstack/ai-harness-cli on their current 0.x versions.

If your project runs on npm 12 and an install now stops on blocked lifecycle scripts, see how to approve npm 12 install scripts.

Step 3: Fix TanStack AI 1.0 breaking changes in the browser

Run your type checker (npx tsc --noEmit or your framework's equivalent) and work through the errors. These are the browser-side changes you will meet most often.

TanStack AI 1.0 rename map from 0.x APIs such as body, conversationId and pendingInterrupts to 1.0 APIs such as forwardedProps, threadId and interrupts
The renames behind most TanStack AI 1.0 type errors
0.x1.0Where
bodyforwardedPropsuseChat, ChatClient, createChatHook
pendingInterruptsinterruptschat hooks
getPendingInterrupts()getInterrupts()ChatClient
interrupt.errorinterrupt.errors[0]interrupts
addToolApprovalResponse()interrupt.resolveInterrupt(true | false)tool approvals

threadId is now required

Every chat hook, generation hook, ChatClient and createChatHook hook call needs a threadId. Use a stable id, such as a conversation id from your database. Do not generate a random one on each render, or every render starts a new thread.

import { useChat, fetchServerSentEvents } from "@tanstack/ai-react";

const { messages, sendMessage } = useChat({
  connection: fetchServerSentEvents("/api/chat"),
  threadId: "support-chat",            // stable id, not crypto.randomUUID() per render
  forwardedProps: { provider: "openai" }, // was: body
});

Two smaller rules come with it. Custom connection adapters receive a run context with threadId as the fourth argument of connect() and send(). On Octane, generation hooks take threadId instead of id.

Keep body in three places: the connection adapter option, the per-call sendMessage option and the generation hooks. The rename only covers the chat-level options.

Tool approvals move to interrupts

addToolApprovalResponse() is gone. A tool marked needsApproval: true now pauses the run and shows up in the interrupts array. You answer it on the interrupt itself:

const { interrupts, resuming } = useChat({
  threadId: "account-42",
  connection: fetchServerSentEvents("/api/chat"),
  tools: [transferTool] as const,
});

{interrupts.map((interrupt) =>
  interrupt.kind === "tool-approval" && interrupt.toolName === "transfer" ? (
    <div key={interrupt.id}>
      <p>Send {interrupt.originalArgs.amount} to {interrupt.originalArgs.recipient}?</p>
      <button disabled={!interrupt.canResolve || resuming}
              onClick={() => interrupt.resolveInterrupt(true)}>Approve</button>
      <button disabled={!interrupt.canResolve || resuming}
              onClick={() => interrupt.resolveInterrupt(false)}>Reject</button>
    </div>
  ) : null
)}

To answer several at once, use the root helpers resolveInterrupts(...) and cancelInterrupts. Nothing goes to the server until every pending item has an answer. Interrupts saved by a 0.x server show up as kind: 'unbound' with canResolve: false, and they cannot be resumed.

Client tools need identical schemas

A client tool now runs only if the server and browser definitions match exactly, including outputSchema. The safe pattern is to define the tool once with toolDefinition() in a shared file, then attach .server() on the server and use the same object on the client.

Prebuilt chat components are gone

Chat, ChatMessages, ChatMessage, ChatInput, ToolApproval and useChatContext were removed. Build the UI with createChatHook from @tanstack/ai-react/ui (or the Solid and Vue equivalents) and supply your own layout, message and input components. TextPart and ThinkingPart are still there. Budget real time for this step if you leaned on the old components, because the codemod cannot do it for you.

Step 4: Update your server routes

On the server, conversationId becomes threadId, and it is required on chat(), summarize() and the generation functions. Read it from the parsed request, not from forwardedProps:

import { chat, chatParamsFromRequest, toServerSentEventsResponse } from "@tanstack/ai";
import { openaiText } from "@tanstack/ai-openai";

export async function POST(request: Request) {
  const params = await chatParamsFromRequest(request);
  const provider = params.forwardedProps.provider; // was: body.data?.provider

  const stream = chat({
    adapter: openaiText("gpt-6.1-sol"),
    messages: params.messages,
    threadId: params.threadId,   // was: conversationId
    runId: params.runId,
  });

  return toServerSentEventsResponse(stream);
}

Extra client fields now arrive only in forwardedProps, and aguiContext replaces context. Middleware reads ctx.threadId. In generation routes, generationParamsFromRequest() throws if the body has no threadId or runId, which is a quick way to find clients you forgot to upgrade. The model id in the example comes from the official quick start; for model choice and pricing, see our GPT-6.1 Terra API migration guide.

Other server changes worth a search:

  • Usage: durationSeconds and unitsBilled are removed. Read billed, which has unit and quantity.
  • Token counts: promptTokens on the Anthropic, Bedrock and Claude Code adapters now includes cache reads and writes. If you added cache tokens yourself, remove that code or you will double count.
  • Video: getVideoUrl() is replaced by getVideo(). In app code, use getVideoJobStatus({ adapter, jobId }).
  • Types: startAssistantMessage() becomes prepareAssistantMessage(), and toolName becomes toolCallName in the renamed server types.
TanStack AI 1.0 migration request flow with threadId and runId from useChat to the server and a RUN_FINISHED event that can carry interrupts
The 1.0 chat request: threadId in, RUN_FINISHED out
View PlantUML source
@startuml
skinparam shadowing false
skinparam defaultFontSize 14
participant "useChat\n(threadId)" as C
participant "API route" as S
participant "chat()" as A
participant "Provider" as P
C -> S : POST messages,\nthreadId, runId,\nforwardedProps
S -> A : chatParamsFromRequest()
A -> P : model call
P --> A : tokens
A --> C : SSE text events
alt tool needs approval
  A --> C : RUN_FINISHED\n+ interrupts
  C -> S : resolveInterrupt(true)
else normal end
  A --> C : RUN_FINISHED
end
@enduml

Custom stream servers

If you wrote your own streaming endpoint instead of using toServerSentEventsResponse(), update the wire format. The 1.0 client follows the AG-UI event rules:

TanStack AI 1.0 stream protocol changes for custom servers, from data DONE and STEP events in 0.x to RUN_FINISHED and REASONING events in 1.0
Custom stream servers: what the 1.0 client expects
0.x server sends1.0 server sends
data: [DONE]a RUN_FINISHED event
nested error messagemessage at the top level of RUN_ERROR
STEP_* thinking eventsREASONING_* events
separate approval messagesinterrupts on RUN_FINISHED

Step 5: Migrate saved data before deploying

This is the step people skip, and it fails only in production. The type checker cannot see what is in your database.

Four TanStack AI 1.0 migration steps for saved data: clear 0.x run records, resolve pending interrupts, add blobKey to artifacts and wrap stored messages
Saved data does not migrate itself
  1. Run records: finish or delete in-progress runs, then clear old rec: records. The Cloudflare sandbox cannot read the 0.x run-log layout, and migrateStoredRunRecord was removed.
  2. Pending interrupts: resolve or drop them. Records saved before interrupt bindings cannot resume.
  3. Artifacts: add blobKey to every artifact record, because it is now required. For 0.x records without one, use artifacts/<runId>/<artifactId>. Custom stores must save it. resolveArtifactBlobKey() was removed.
  4. Client persistence: getItem must return { messages } (plus an optional resume), not a bare array.

A small shim covers old localStorage data:

getItem: (id) => {
  const saved = JSON.parse(localStorage.getItem(id) ?? "null");
  return Array.isArray(saved) ? { messages: saved } : saved;
},

In sandbox code, FileEvent is now SandboxFileEvent.

TanStack AI 1.0 done check

The upgrade guide ends with a simple check. Run your type checker, then search for names that no longer exist:

npx tsc --noEmit
grep -rnE "pendingInterrupts|resumeInterrupts\(|addToolApprovalResponse|conversationId|getVideoUrl|durationSeconds|unitsBilled|body\.data" src

Zero matches is the goal. Then test two things by hand: a chat streams a reply, and a saved chat still loads after a page reload.

TanStack AI 1.0 migration checklist with six items: codemod, package versions, type check, grep for removed names, saved data, and a streaming plus reload test
Run this list before you merge the upgrade

Common errors after the upgrade

SymptomLikely causeFix
Type error: threadId is missingHook or chat() call without itPass a stable id on both sides
Server can't see your custom fieldStill reading body.dataRead params.forwardedProps
Stream never ends in the UICustom server still sends [DONE]End with RUN_FINISHED
Approval buttons do nothingOld interrupt from a 0.x serverShows as unbound; drop it and retry
Client tool never runsSchemas differ between server and clientShare one toolDefinition()
Token cost looks doubledManual cache tokens added on topRemove the extra addition

FAQ

Is TanStack AI 1.0 production ready? The core APIs are, according to the 1.0 announcement: "The core APIs are stable and ready for production." The agent harness (@tanstack/ai-harness and related entry points) is still experimental and stays on 0.x.

Can I upgrade only the client or only the server? No. The guide says a 1.0 client needs a 1.0 server. Upgrade every stable @tanstack/ai* package together and deploy both sides at the same time.

Does the codemod do the whole TanStack AI 1.0 migration? No. It renames body, updateBody and conversationId keys. You still need to fix body.data reads, threadId values, tool approvals, the removed UI components, custom stream servers and stored data.

What replaces @tanstack/ai-react-ui? Nothing directly. Build your chat UI with createChatHook from @tanstack/ai-react/ui and your own components. TextPart and ThinkingPart are still exported.

Do I need to migrate data if I never store chats? If you keep chats only in memory, there is nothing to migrate. If you use client persistence, server run records, interrupts or artifacts, follow the four saved-data steps before you deploy.

References

Leave a Comment