Subpath exports keep React and Studio out of query-only pages

Published: November 10, 2026

v3.0.0

@sanity/sveltekit 3.0.0 splits the package’s single entry point into subpath exports. In Vite dev, pages that only query content no longer pull in React and Sanity Studio. Export names are unchanged, but most imports move to a new path, so this is a breaking change.

Update your imports

Import each export from its subpath:

  • @sanity/sveltekit/query: QueryLoader, handleQueryLoader, loadQuery, setServerClient, useLiveMode, useQuery
  • @sanity/sveltekit/preview: PreviewMode, handlePreviewMode
  • @sanity/sveltekit/visual-editing: VisualEditing, SuspiciousStegaReport
  • @sanity/sveltekit/live: LiveLoader, handleLiveLoader, sanityFetch
  • @sanity/sveltekit/studio: SanityStudio
  • @sanity/sveltekit/optimistic: useOptimistic, optimisticActor
  • @sanity/sveltekit/context: getEnvironment, getPerspective, getIsPreviewing, getLoader, and their types

These stay on the root @sanity/sveltekit import: createClient, stegaClean, defineQuery, groq, createDataAttribute, and the SanityLocals and VisualEditingProps types. Each handle* function’s config type moves with it, for example HandlePreviewModeConfig to @sanity/sveltekit/preview.

For example, a server hooks file that uses the Query Loader changes like this:

// Before
import {handlePreviewMode, handleQueryLoader, setServerClient} from '@sanity/sveltekit'

// After
import {handlePreviewMode} from '@sanity/sveltekit/preview'
import {handleQueryLoader, setServerClient} from '@sanity/sveltekit/query'

Install sanity to embed Studio

sanity is now an optional peer dependency, so it isn’t installed with @sanity/sveltekit. If your app embeds Studio with SanityStudio, install it yourself:

npm install sanity

Removed context setters

The undocumented setIsPreviewing, setPerspective, setEnvironment, and setLoader functions are no longer exported. The matching getters are available from @sanity/sveltekit/context.

The Visual Editing with SvelteKit guide now uses the new import paths.

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