Client API CDN configuration

Sanity provides a CDN-distributed, cached API that is faster and cheaper to use if you are exposing the API to end users. If you are building static sites, use the live API to ensure you always get the freshest version.

A full explanation of the differences between these APIs is outlined in the API CDN documentation.

The Sanity JavaScript client can be configured to use either the API CDN or the live API by setting the useCdn option to true or false, respectively, when configuring the client:

import {createClient} from '@sanity/client'

const client = createClient({
  projectId: '',
  dataset: '',
  apiVersion: '2026-03-01',
  useCdn: true,
})

Protip

The client automatically falls back to using the live API in the following scenarios:

  • When a mutation is performed (create/edit/delete).
  • When listeners are used (subscribing to changes).

Setting useCdn: false on a client that renders published content for every visitor sends each of those queries to the live API, which counts toward your API request quota. To find out what is driving your API requests, see Diagnose an API request spike.

Was this page helpful?

sanity.ioAll Systems Operational© Sanity 2026
Change site theme