Ships ESM only, plus Visual Editing without React

Published: November 16, 2026

v4.0.0

@sanity/astro 4.0.0 ships an ESM-only build. Projects that import the package through its documented entry points need no changes. The release also runs Visual Editing without React, and adds an experimental in-place preview refresh and experimental loaders for Astro live collections.

Action required

  • Who's affected: tooling or code that relies on the removed UMD bundle, the removed module export condition, or files under the package's src/ directory, which is no longer published.
  • What to do: import from the package's entry points instead: @sanity/astro, @sanity/astro/loader, @sanity/astro/visual-editing, @sanity/astro/visual-editing/component, and the @sanity/astro/studio/* routes. These now resolve to files in dist/.
  • By when: when you upgrade to 4.0.0. Imports that point at the removed files fail to resolve.

New features

Visual Editing without React

<VisualEditing /> from @sanity/astro/visual-editing no longer needs @astrojs/react, so sites built only from .astro files get click-to-edit overlays in the Presentation Tool by adding one component. See Visual Editing with Astro.

---
import { VisualEditing } from "@sanity/astro/visual-editing";
// draftMode: your draft mode check
---
<VisualEditing enabled={draftMode} />

Refresh the preview in place

Set experimental_refreshStrategy="in-place" on <VisualEditing /> to update the preview without reloading the page. Text updates as editors type, then the page morphs to the fresh server HTML, so scroll position and focus survive. See Refresh the preview without reloading the page.

{/* draftMode: your draft mode check */}
<VisualEditing enabled={draftMode} experimental_refreshStrategy="in-place" />

Live collection loaders

On Astro 6 and later, set the experimental_live integration option to generate typed loaders and Zod schemas from your Sanity schema for Astro live collections, which fetch content on every request instead of at build time. Nothing is extracted or generated unless you set the option. See Live collections in the @sanity/astro README.

Improvements

  • Configuration: the new env option reads projectId and dataset from environment variables when the server runs, so one build can serve several projects or datasets. Requires Astro 5 or later. See Configuring @sanity/astro.
  • Visual Editing: the new visualEditingStandalone option runs the overlays on @sanity/visual-editing-standalone, which bundles its own React, React DOM, and styled-components.
  • Loader: @sanity/astro/loader exports the experimental createSanityLiveLoader.

Fixes

  • Visual Editing: in astro dev, the overlays of <VisualEditing /> no longer fail with "Invalid hook call" in projects that don’t install React themselves. The integration now dedupes and pre-bundles React, styled-components, and sanity only when your project installs them.

For the full list of changes, see the @sanity/astro 4.0.0 release on GitHub.

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme