sanity-live-cache-components
Sanity Live + Cache Components
Wires next-sanity into a Next.js 16+ app with cacheComponents: true. Data is fetched with sanityFetch (which calls cacheTag/cacheLife internally), and <SanityLive> in the root layout revalidates cached content over an EventSource connection to Sanity Content Lake. Visual Editing and Presentation Tool are fully supported when draft mode is enabled.
Read the relevant guide in node_modules/next/dist/docs/ (when available) before writing code. If a guide conflicts with this skill, follow this skill.
This skill assumes familiarity with the next-cache-components skill — it covers 'use cache', cacheLife, cacheTag, and the cookies/headers/params rule. The only Sanity-relevant exception: await draftMode() is allowed inside 'use cache' (Next.js bypasses caching when draft mode is enabled — see the use cache reference).
Prerequisites
- Next.js 16.2+ installed in the project (check
package.jsonor runpnpm list next/npm ls next— don't usepnpm view next version, that reports the registry's latest, not what's installed). AGENTS.mdexists, or follow the guide.- These environment variables are set:
NEXT_PUBLIC_SANITY_PROJECT_IDNEXT_PUBLIC_SANITY_DATASETSANITY_API_READ_TOKEN
- Embedded Sanity Studio configuration (
sanity.config.ts,sanity.cli.ts, anything undersanity/) needs no changes — this skill only touches the Next.js app surface.