| name | sanity-visual-editing-setup |
| description | Configures Sanity Visual Editing for your front-end framework. Use when setting up live preview or click-to-edit overlays. |
Visual Editing Setup
This skill inspects the project and installs/configures the necessary packages for Sanity Visual Editing.
Procedure
Detect Framework
- Check
package.jsondependencies. - Identify:
next,react-router,@remix-run/react,svelte,nuxt,astro.
- Check
Install Dependencies
- Next.js:
npm install next-sanity @sanity/client(Ensure v11+ fornext-sanity) - Remix:
npm install @sanity/react-loader @sanity/client @sanity/visual-editing - Svelte:
npm install @sanity/svelte-loader @sanity/client @sanity/visual-editing - Nuxt:
npm install @nuxtjs/sanity - Astro:
npm install @sanity/astro
- Next.js:
Configure Client (Stega)
- Locate the Sanity Client config (e.g.,
sanity/client.ts,lib/sanity.ts). - Update the configuration to include
stega: { enabled: true, studioUrl: '...' }. - Crucial: Ensure
useCdnlogic is correct (usuallyfalsefor live preview).
- Locate the Sanity Client config (e.g.,
Configure Loaders (Framework Specific)
- Next.js: Setup
defineLiveinsanity/lib/live.ts. Add<SanityLive />to layout. - Remix: Setup
loader.server.ts(server-only) andloader.ts(shared). ImplementuseQuery. - Svelte: Setup
hooks.server.ts(createRequestHandler) and+layout.svelte(useLiveMode).
- Next.js: Setup
Verification
- Ask user to run the dev server.
- Check if overlays appear in the Presentation Tool (iframe).