Ships ESM only, plus Visual Editing without React
Published: November 16, 2026
@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
moduleexport condition, or files under the package'ssrc/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 indist/. - 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
envoption readsprojectIdanddatasetfrom 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
visualEditingStandaloneoption runs the overlays on@sanity/visual-editing-standalone, which bundles its own React, React DOM, and styled-components. - Loader:
@sanity/astro/loaderexports the experimentalcreateSanityLiveLoader.
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, andsanityonly when your project installs them.
For the full list of changes, see the @sanity/astro 4.0.0 release on GitHub.
Related documentation
Visual Editing with Astro
Configure Sanity’s Presentation Tool, draft mode, and visual editing overlays to work with an Astro 7 server-rendered frontend.
Sanity and Astro
Build content-driven Astro websites with Sanity. The integration, key features, and resources to get started.
Configuring @sanity/astro
Reference for Sanity integration configuration in Astro. Covers integration options, the sanity:client virtual module, environment variables, type declarations, and creating additional client instances.