Skip to content

Sanity published changes not showing on your Next.js site

Published in Sanity Studio but your live site still shows old content? Fix Next.js caching with revalidateTag webhooks, useCdn: false, dataset mismatches, and drafts.

Updated 3 December 2026Tested with
  • sanity 6.24.0
  • next-sanity 13.5.1
  • Next.js 16.4.6

You hit Publish in Sanity Studio, refresh your live Next.js site, and the old text is still there. That happens for one of four reasons: Next.js cached the static route at build time with no revalidation webhook, your Sanity client has useCdn: true, the query filters out the document (wrong perspective or slug), or you published to a different dataset than production reads.

Check these four things in order

  1. Step 1: Next.js cached the page (no webhook or revalidateTag)

    In Next.js App Router, statically generated pages stay cached until you either set a time-based revalidate or trigger on-demand revalidation from a Sanity webhook. Tag your Sanity fetches and expose a small webhook route:

    src/sanity/fetch.tsTypeScript
    export async function sanityFetch<T>(query: string, params = {}, tags: string[] = []) {  return client.fetch<T>(query, params, {    next: { revalidate: tags.length ? false : 60, tags },  });}
    app/api/revalidate/route.tsTypeScript
    import { revalidateTag } from "next/cache";import { parseBody } from "next-sanity/webhook";import { NextResponse, type NextRequest } from "next/server"; export async function POST(req: NextRequest) {  const { isValidSignature, body } = await parseBody<{ _type: string }>(    req,    process.env.SANITY_REVALIDATE_SECRET,  );  if (!isValidSignature) return NextResponse.json({ message: "Invalid signature" }, { status: 401 });  if (body?._type) revalidateTag(body._type, "max");  return NextResponse.json({ revalidated: body?._type ?? null });}

    Then create a GROQ-powered webhook in sanity.io/manage › API › Webhooks pointing to https://yourdomain.com/api/revalidate with the same secret.

  2. Step 2: useCdn: true returns a stale edge response

    Sanity's API CDN (apicdn.sanity.io) caches query results for a short window after publish. When you already cache pages in Next.js (with ISR or revalidateTag), set useCdn: false on the server client so Next.js always fetches the freshly published document when it revalidates:

    src/sanity/client.tsTypeScript
    export const client = createClient({  projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,  dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,  apiVersion: "2026-11-01",  useCdn: false,});
  3. Step 3: Studio and production point to different datasets

    Check NEXT_PUBLIC_SANITY_DATASET in your host's environment variables (Vercel, Cloudflare Workers, Netlify) against the dataset selected in Sanity Studio. Editing in staging while production reads production is a classic silent mismatch.

  4. Step 4: Document is still a draft or has a broken reference

    Unpublished documents have an ID starting with drafts. and are excluded by default under perspective: "published". If a parent page references a newly created author or category that is still a draft, the referenced fields resolve to null on the live site until the referenced document is also published.

Questions

Does setting useCdn: false increase my Sanity API bill?

Only if every visitor hits the uncached API. When Next.js caches the route and only refetches on webhook or every 60 seconds, useCdn: false sends one API request per publish instead of one per visitor. You can estimate your monthly usage with our Sanity pricing calculator.

My browser console shows a CORS error when previewing drafts

That is a separate setting in Sanity's dashboard. Follow Fix Sanity CORS errors to add your preview origin with credentials enabled.

Where can I get ready-made Sanity schemas for Next.js and Astro?

Browse our free Sanity content models (posts, authors, FAQs, events, jobs) — copy the schema or install it with the shadcn CLI.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

Building with shadcn/ui and Tailwind CSS v4?

Install 188 free blocks and components with the shadcn CLI (no account), preview them in your own brand in Studio, or get all 1,570 blocks and every theme in UI Pro (€199 once).

Use it with

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components, included in UI Pro.