{"record":{"id":"b3ca216a2aa4f902","repo":"vercel/ai","slug":"unsupported-react-version","errorCode":null,"errorMessage":"Unsupported React version.","messagePattern":"Unsupported React version\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/rsc/src/shared-client/context.tsx","lineNumber":31,"sourceCode":"  InternalAIProviderProps,\n  ValueOrUpdater,\n} from '../types';\n\nconst InternalUIStateProvider = React.createContext<null | any>(null);\nconst InternalAIStateProvider = React.createContext<undefined | any>(undefined);\nconst InternalActionProvider = React.createContext<null | any>(null);\nconst InternalSyncUIStateProvider = React.createContext<null | any>(null);\n\nexport function InternalAIProvider({\n  children,\n  initialUIState,\n  initialAIState,\n  initialAIStatePatch,\n  wrappedActions,\n  wrappedSyncUIState,\n}: InternalAIProviderProps) {\n  if (!('use' in React)) {\n    throw new Error('Unsupported React version.');\n  }\n\n  const uiState = React.useState(initialUIState);\n  const setUIState = uiState[1];\n\n  const resolvedInitialAIStatePatch = initialAIStatePatch\n    ? (React as any).use(initialAIStatePatch)\n    : undefined;\n  initialAIState = React.useMemo(() => {\n    if (resolvedInitialAIStatePatch) {\n      return jsondiffpatch.patch(\n        jsondiffpatch.clone(initialAIState),\n        resolvedInitialAIStatePatch,\n      );\n    }\n    return initialAIState;\n  }, [initialAIState, resolvedInitialAIStatePatch]);\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/rsc/src/shared-client/context.tsx#L13-L49","documentation":"InternalAIProvider runs on the client and relies on React's `use()` hook (React 19 / the `use` proposal). The SDK checks `'use' in React` and throws if the hook is missing, because the client context streams AI state through `React.use`. Older React versions without `use` cannot drive the provider.","triggerScenarios":"Rendering the client-side `<AI>` provider with React 17 or React 18 without the `use` experimental/stable hook available; pinning an old `react`/`react-dom` version while using a recent `ai` package; package-manager dedupe resolving an older React copy.","commonSituations":"Upgrading `ai` but not `react`/`next`; a stale lockfile keeping React 18.x installed; using `ai/rsc` outside Next.js canary versions that shipped React 19 features.","solutions":["Upgrade to React 19 (or the Next.js version that ships it): `pnpm add react@latest react-dom@latest`","Upgrade Next.js to a version compatible with React 19 if applicable","Run your package manager's dedupe/install to remove stale React 17/18 copies (`pnpm install`, `npm dedupe`)","Check `require('react').use` / `'use' in React` in your app to confirm the resolved version"],"exampleFix":"// before (package.json)\n\"react\": \"^18.2.0\",\n\"react-dom\": \"^18.2.0\"\n// after (package.json)\n\"react\": \"^19.0.0\",\n\"react-dom\": \"^19.0.0\"","handlingStrategy":"validation","validationCode":"// run once at app entry (client)\nif (typeof React === 'undefined' || !('use' in React)) {\n  throw new Error('This app requires React 19+ (with the `use` hook) for ai/rsc');\n}","typeGuard":"function supportsReactUse(react: typeof React): react is typeof React & { use: unknown } {\n  return 'use' in react;\n}","tryCatchPattern":"try {\n  root.render(<AI>{children}</AI>);\n} catch (err) {\n  if (String(err).includes('Unsupported React version')) {\n    console.error('Upgrade react/react-dom to ^19');\n  }\n  throw err;\n}","preventionTips":["Pin react/react-dom to a version matching the ai package's peerDependencies","After upgrading ai, run install/dedupe and verify the resolved React version","Avoid multiple React copies in the lockfile","Test the provider render in CI with the production React build"],"tags":["react","version-compatibility","dependency-mismatch","rsc"],"backgroundTag":"react-version-unsupported","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}