{
  "id": 22588091,
  "title": "Sanity client misconfigured in Next.js? apiVersion, useCdn and perspective fixes",
  "url": "https://urgent.news/2026/11/29/sanity-client-misconfigured-in-next-js-apiversion-usecdn-and",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-29T13:39:04.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/nayankyada/sanity-client-misconfigured-in-nextjs-apiversion-usecdn-and-perspective-fixes-45g1"
  },
  "original_language": null,
  "account": "Sanity client misconfiguration is a common issue in Next.js projects, leading to stale content, duplicate entries, high API request counts, and inconsistent queries. The three main settings that cause problems are apiVersion, useCdn, and perspective. These settings are usually hardcoded in a small configuration file that nobody opens after the initial commit.\n\nThe most frequent issue is an outdated or missing apiVersion, which causes the query API to use old behaviour. Fixing this requires setting a fixed date string for the version, rather than relying on the current date.\n\nAnother common problem is incorrectly configuring useCdn. If set to false, every page build and cache miss will hit the live API, increasing latency and request counts. On the other hand, if set to true in draft or write-then-read code, the CDN may serve slightly older responses, causing stale previews and server actions.\n\nThe wrong perspective setting can also lead to issues. Using the wrong perspective (published, drafts, or raw) can result in unpublished content appearing on the live site, each document appearing twice, or the preview mode not working as expected.\n\nLastly, a single client trying to serve multiple roles (public pages, draft previews, and server-side writes) can cause problems. It is cleaner to have two clients with explicit settings for each role. By doing this, you can ensure that public pages only use the CDN and see published content, while draft mode fetches fresh reads and drafts layered over published content.",
  "summary": "If you inherited a Next.js site and the Sanity content is stale, leaking drafts, or oddly expensive to fetch, look at the Sanity client configuration before you touch anything else. Three settings, apiVersion, useCdn and perspective, cause a surprising share of the problems I see on inherited projects. They sit in one small file that nobody has opened since the first commit. Symptoms of a…",
  "summary_source": "publisher",
  "key_points": [
    "apiVersion misconfiguration leads to stale content",
    "Incorrect useCdn setting causes high request counts",
    "Wrong perspective setting results in duplicate entries"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}