React 19 and Sanity
Support for React 19 in Sanity Studio and official plugins are being worked on. Progress can be tracked on this page.
You can use Sanity in Next.js 15 by downgrading the React dependencies to version 18.
Next.js 15 will still use React 19, but this will ensure compatibility with other packages depending on React 18. Run the following command to install this version of React.
npm install react@18 react-dom@18 --legacy-peer-deps
Your package.json
should now show react
and react-dom
as
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
// ...all other packages
}
It depends on the plugins you use. Our release strategy is to:
- Update upstream libraries that Sanity Studio depends on with React 19 support (
@sanity/ui
,react-rx
, and others). - Release a new version of Sanity Studio that adds React 19 to its
peerDependencies
and passes the build test. - Update
@sanity/plugin-kit
with support for React 19, and provide docs for plugin authors for how to test, verify and release a new version. - Release new versions of official plugins that adds React 19 to its
peerDependencies.
- Help third party plugin authors with upgrading their plugins to add React 19.
Make sure you’ve upgraded to React 18.3 or later, and that you don’t have any deprecation warnings logged to your console when running sanity dev
.
Also ensure you have reactStrictMode
enabled and don’t have strict mode related warnings either.
Depending on your package manager you may get peer dependency errors or warnings that prevent you from being able to test 19. Here’s how you can configure your package manager to let you test 19 today:
Version v10 is recommended.
Start by adding these overrides to your package.json
:
{
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sanity": "^3.43.0",
},
"packageManager": "npm@10.5.2",
"overrides": {
"react": "$react",
"react-dom": "$react-dom"
}
}
Run npm install
and you shouldn’t see any errors. Next, upgrade react
and react-dom
:
npm i react@rc react-dom@rc --save-exact
Version v9 is recommended.
Start by adding an overrides
field that ensures you don't get both v18 and v19 of react installed:
{
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sanity": "^3.43.0",
},
"packageManager": "pnpm@9.0.4",
"pnpm": {
"pnpm": {
"peerDependencyRules": {
"allowAny": [
"react",
"react-dom"
]
}
}
}
}
Then run:
pnpm up react@rc react-dom@rc
v1 or later is recommended.
bun add react@rc react-dom@rc
v1 is recommended.
yarn add react@rc react-dom@rc