vercel/ai · error
Unsupported React version.
Error message
Unsupported React version.
What it means
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.
Source
Thrown at packages/rsc/src/shared-client/context.tsx:31
InternalAIProviderProps,
ValueOrUpdater,
} from '../types';
const InternalUIStateProvider = React.createContext<null | any>(null);
const InternalAIStateProvider = React.createContext<undefined | any>(undefined);
const InternalActionProvider = React.createContext<null | any>(null);
const InternalSyncUIStateProvider = React.createContext<null | any>(null);
export function InternalAIProvider({
children,
initialUIState,
initialAIState,
initialAIStatePatch,
wrappedActions,
wrappedSyncUIState,
}: InternalAIProviderProps) {
if (!('use' in React)) {
throw new Error('Unsupported React version.');
}
const uiState = React.useState(initialUIState);
const setUIState = uiState[1];
const resolvedInitialAIStatePatch = initialAIStatePatch
? (React as any).use(initialAIStatePatch)
: undefined;
initialAIState = React.useMemo(() => {
if (resolvedInitialAIStatePatch) {
return jsondiffpatch.patch(
jsondiffpatch.clone(initialAIState),
resolvedInitialAIStatePatch,
);
}
return initialAIState;
}, [initialAIState, resolvedInitialAIStatePatch]);
View on GitHub (pinned to 69428b1f8b)
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
Example fix
// before (package.json) "react": "^18.2.0", "react-dom": "^18.2.0" // after (package.json) "react": "^19.0.0", "react-dom": "^19.0.0"
Defensive patterns
Strategy: validation
Validate before calling
// run once at app entry (client)
if (typeof React === 'undefined' || !('use' in React)) {
throw new Error('This app requires React 19+ (with the `use` hook) for ai/rsc');
} Type guard
function supportsReactUse(react: typeof React): react is typeof React & { use: unknown } {
return 'use' in react;
} Try / catch
try {
root.render(<AI>{children}</AI>);
} catch (err) {
if (String(err).includes('Unsupported React version')) {
console.error('Upgrade react/react-dom to ^19');
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- `useSyncUIState` must be used inside an <AI> provider.
- ${method}: Value stream is already closed.
- ${method}: Value stream is locked and cannot be updated.
- .append(): The current value is not a string. Received: ${ty
- .append(): The value is not a string. Received: ${typeof val
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/b3ca216a2aa4f902.
Report an issue: GitHub.