
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a known issue that can occur after upgrading Sanity Studio, particularly when moving from v2 to v3. The "React is not defined" error typically happens due to build configuration issues. Here's how to fix it:
Before making any configuration changes, try clearing your build artifacts:
rm -rf node_modules/.sanity
rm -rf node_modules/.cache
rm -rf .sanityThen reinstall dependencies:
npm install
# or
yarn installIf clearing the cache doesn't resolve it, check your tsconfig.json. According to the Sanity Studio configuration documentation, the correct default setting for Sanity Studio v3 is:
{
"compilerOptions": {
"jsx": "preserve",
// ... other options
}
}The "jsx": "preserve" setting is the standard for Sanity Studio v3. However, if you're still getting "React is not defined" errors with this setting, it may be due to:
.jsx or .tsx extensionsVerify your Node version: Sanity Studio v3 requires Node.js 18 or higher. Studio v4 requires Node.js 20+. Check with:
node -vCheck your sanity.config file extension: If you have custom components with JSX in your sanity.config.js, rename it to sanity.config.jsx or sanity.config.tsx. Vite requires the proper extension for JSX transformation.
Review custom components: If you have custom input components or plugins, make sure any files containing JSX have the correct file extension (.jsx or .tsx).
Verify the upgrade completed: Run sanity upgrade again to ensure all packages are properly updated:
sanity upgradeThe most common cause of this error after upgrading is stale build cache combined with the new Vite bundler's stricter requirements about file extensions. The cache-clearing step resolves this in most cases.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store