Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change Site Theme
Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Agent Actions
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates
Help articles
Overview

  • Array items resolve to same JSON type
  • Studio Performance Issues Caused by legacy HTTP protocols
  • Error: Value of type "object" is not allowed in this array field
  • AVIF
  • Experimental feature: Spaces
  • Client API CDN configuration
  • Total attribute count exceeds limit
  • Desk is now Structure
  • Invalid configuration for cross dataset reference
  • Missing or duplicate context error
  • Sanity Studio v2 is deprecated
  • React Compiler and Sanity
  • Specify API version for studio client
  • Why give schema types a title?
  • Array type has a invalid value for property "of"
  • React 19 and Sanity
  • Schema: Lift anonymous object types
  • Reference type has a invalid value for property "to"
  • Incorrect location for reference options
  • Invalid part syntax
  • Asset metadata field
  • Warning: userStore.currentUser is deprecated
  • CLI errors
  • Renamed plugin sanity-plugin-vision
  • Part name format
  • Array member type name is the same as a global type
  • Changes in block schema customization properties
  • How to migrate from date to richDate
  • Invalid shape of predefined choices
  • JS Client: Promise Polyfill
  • Introducing the document type
  • Unable to get a ref to an input component
  • Authenticating the CLI when running remotely
  • Outdated modules
  • Upgrade studio packages
  • Block Content rendering: Image materializing
  • Structure: Document schema type required
  • Parts: Declare vs implement
  • Incorrect options declaration in reference
  • Block type cannot be used outside of array
  • Structure: Node ID required
  • Structure: List items must be an array
  • Installing Node.js
  • Structure: Action or intent required
  • Object type has a invalid value for fields
  • `studioHost` and `externalStudioHost` properties deprecated
  • Schema type is ES Module but imported through require
  • Structure: Invalid list item
  • Structure: Query provided where filter is expected
  • Structure: List item IDs must be unique
  • Given type name is a reserved type
  • Structure: Schema type not found
  • API versioning
  • Migrating the legacy webhook behavior to GROQ-powered Webhooks
  • Schema type is invalid
  • Input component is missing a required prop
  • Structure: Title is required
  • Structure: Filter is required
  • Import: Asset file does not exist
  • Input component is missing a required method
  • Implementing non-overridable part
  • Structure: Item returned no child
  • How to migrate your block text schema for the new definition of inline objects
  • Structure: Schema type is required
  • How to migrate from blocks spans to block children
  • Array type cannot contain array member
  • Using tokens in the browser
  • GraphQL
  • Array member type name conflicts with built-in type
  • Source vs. compiled paths
  • Import: Asset has different target than source
  • Using global studio client without specifying API version
  • Structure: Action and intent are mutually exclusive
  • Upgrade React
  • Plugin is missing a sanity.json file
  • Structure: Document ID required
  • Incompatible combination of params and filter
  • Using listener with tokens is not supported in browsers
  • Schema type is missing a required property
  • API versioning in Javascript Client
  • Upgrade version of studio package
  • Slug: `slugifyFn` renamed
  • Renamed plugin @sanity/date-input
  • Specify API version when using custom document list filters
  • Migration Cheat Sheet: Studio v2 to v3
  • Migrating from Studio v2
  • Function Timeout
  • Functions rate limit
  • Configure TypeGen
  • Studio v3 to v4
  • Email addresses show [email protection]

On this page

Previous

Sanity Studio v2 is deprecated

Next

Specify API version for studio client

Was this page helpful?

On this page

  • Sanity Studio
  • React 18
  • React 19
  • Embedded Studios
  • Publishing Sanity plugins and tools
  • Troubleshooting
Help articlesLast updated November 19, 2025

React Compiler and Sanity

Learn how to use the React Compiler with Sanity Studio, React 18 & 19, and for publishing Sanity plugins. Improve performance and reduce manual memoization.

Sanity Studio v3.65.0 introduced support for the React Compiler. The compiler improves performance by automatically optimizing component rendering. This reduces the amount of manual memoization developers have to do through APIs such as useMemo and useCallback.

If you use @sanity/pkg-utils and/or @sanity/plugin-kit to distribute custom plugins and tools on npm then it's also possible to use the compiler there.

Sanity Studio

Install the babel and ESLint plugins for the compiler

npm install --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
pnpm add --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
yarn add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
bun add --dev babel-plugin-react-compiler eslint-plugin-react-hooks

Setup your ESLint config to include the compiler, it’s included in the recommended preset

import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat.recommended,
]);

You don't need to fix all the warnings before you can start using the compiler, you can incrementally adopt it.

It's also recommended that you have strictNullChecks enabled.

React 18

Install the react-compiler-runtime package as a direct dependency

npm install react-compiler-runtime
pnpm add react-compiler-runtime
yarn add react-compiler-runtime
bun add react-compiler-runtime

And add reactCompiler to your sanity.cli.ts configuration, and set target to '18'

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
   api: {
      projectId: 'abc123',
      dataset: 'production',
   },
   reactStrictMode: true,
   reactCompiler: {target: '18'},
})

React 19

And add reactCompiler to your sanity.cli.ts configuration, and set target to '19'

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
   api: {
      projectId: 'abc123',
      dataset: 'production',
   },
   reactStrictMode: true,
   reactCompiler: {target: '19'},
})

Since React 19 has the compiler runtime built in there's no need to install react-compiler-runtime.

Embedded Studios

If your studio is hosted inside something like a Next.js, Remix app or otherwise not using sanity build and sanity dev commands?

If so you'll have to enable the compiler through one of the methods documented here.

Publishing Sanity plugins and tools

Since the compiler needs to run on the original source code it's not possible for Sanity Studio's to compile the libraries they use. Instead, library authors need to ship compiled code to npm.

At Sanity we use @sanity/pkg-utils to build our libraries. It handles ESM, CJS, and even the React Compiler. Libraries like react-rx, @sanity/ui and @portabletext/editor, sanity, and @sanity/vision, are already shipping compiled code this way.

Start off by installing the ESLint and Babel plugins

npm install --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
pnpm add --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
yarn add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
bun add --dev babel-plugin-react-compiler eslint-plugin-react-hooks

Since v7 of eslint-plugin-react-hooks the new React Compiler checks are included in the recommended preset.

import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat.recommended,
]);

You don't need to fix all the warnings before you can start using the compiler, you can incrementally adopt it.

It's also recommended that you have strictNullChecks enabled.

You also need to install the react-compiler-runtime if you support react 18

npm install react-compiler-runtime
pnpm add react-compiler-runtime
yarn add react-compiler-runtime
bun add react-compiler-runtime

It's very important that the direct dependency you use, use an exact version number.

Next, you add two lines of code to your package.config.ts

import {defineConfig} from '@sanity/pkg-utils'

export default defineConfig({
  // ... other stuff
  babel: {reactCompiler: true},
  reactCompilerOptions: {target: '18'}, // matches the minimum `react` major your library requires
})

Troubleshooting

Follow the official troubleshooting docs in case you run into problems. In our experience it's incredibly rare for the compiler to create a regression, it typically choses to skip over optimizing components it deems unsafe, or too complex to safely memoize.

Should a rare problem occur it's often enough to add 'use no memo' at the top of the affected file, to buy you time and find the fix. And then use ESLint with eslint-plugin-react-hooks to find issues that could be the root cause. Running React Strict Mode is also incredibly helpful to uncover root issues.

npm install --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
pnpm add --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
yarn add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
bun add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
npm install --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
pnpm add --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
yarn add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
bun add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat.recommended,
]);
npm install react-compiler-runtime
pnpm add react-compiler-runtime
yarn add react-compiler-runtime
bun add react-compiler-runtime
import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
   api: {
      projectId: 'abc123',
      dataset: 'production',
   },
   reactStrictMode: true,
   reactCompiler: {target: '18'},
})
import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
   api: {
      projectId: 'abc123',
      dataset: 'production',
   },
   reactStrictMode: true,
   reactCompiler: {target: '19'},
})
npm install --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
pnpm add --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
yarn add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
bun add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
npm install --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
pnpm add --save-dev babel-plugin-react-compiler eslint-plugin-react-hooks
yarn add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
bun add --dev babel-plugin-react-compiler eslint-plugin-react-hooks
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat.recommended,
]);
npm install react-compiler-runtime
pnpm add react-compiler-runtime
yarn add react-compiler-runtime
bun add react-compiler-runtime
import {defineConfig} from '@sanity/pkg-utils'

export default defineConfig({
  // ... other stuff
  babel: {reactCompiler: true},
  reactCompilerOptions: {target: '18'}, // matches the minimum `react` major your library requires
})