Yuri Osipov · Founder, SEO & analytics

Sanity CMS: structured content in someone else’s cloud

Sanity’s pitch is that content is data, not pages. That sounds like marketing until you see a schema where a “post” has a typed slug, a reference to an author, and a localised array of blocks — and every one of those is queryable. For a site with real structure, that is the difference between a CMS and a folder of text.

In short

What Sanity actually is

Two parts, one product. The Content Lake is a hosted, CDN‑backed store for JSON documents with references, drafts and an asset pipeline. The Studio is a React application you configure with TypeScript and can deploy anywhere.

// sanity.config.ts
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
import { post } from './schema/post'

export default defineConfig({
  projectId: process.env.SANITY_STUDIO_PROJECT_ID!,
  dataset: 'production',
  schema: { types: [post] },
  plugins: [structureTool()],
})

A field can be a string, a Portable Text array, a reference, an image with a hotspot, or a nested object. Documents can be localised field by field rather than as whole pages, which is what multilingual sites usually need.

Who it fits

It fits badly when the content model is genuinely simple, when procurement forbids another SaaS subscription, or when the budget is a single fixed project fee with no room for a monthly line.

How it connects to Astro

// src/lib/sanity.ts
import { sanityClient } from 'sanity:client'

const POSTS = /* groq */ `*[_type == "post"] | order(publishedAt desc) {
  title,
  "slug": slug.current,
  publishedAt,
  "author": author->name
}`

export const getPosts = () => sanityClient.fetch(POSTS)

sanity:client is a virtual module created by @sanity/astro from your environment variables, so there is no client boilerplate. The integration also provides an image URL helper that respects the hotspot and crop set in the Studio — useful, because cropping in the CMS and then cropping again in CSS is how faces get cut in half.

For images in Astro’s own pipeline, add the Sanity CDN to the allowed remote patterns; for everything else, the helper is enough.

Drafts are the one part that is not static. Add an on‑demand route (or a separate preview deployment) that fetches with a token, and wire Sanity’s Presentation tool to it. Public pages stay prerendered; the preview runs on demand.

Strengths

Weaknesses

The ownership question

Worth saying plainly: with Sanity you rent the content layer. The Studio is yours, the schema is yours, the queries are yours — the storage is not. For most clients that is a fair trade, the same way nobody insists on hosting their own email. It becomes a problem the day a procurement rule, a data residency requirement or a sudden price change makes the vendor a risk rather than a convenience. Ask that question before the migration, not after.

When to choose Sanity

Choose Sanity when the content operation is the product: many editors, several locales, and a need for structured data that other systems consume. It is also the sane default when nobody on the team wants to be responsible for a database at 2 a.m.

If instead you want the CMS in your repository and your own infrastructure, read the Payload guide. If the priority is editing the page visually with a component library, Storyblok is closer to that shape.

Summary

Sanity trades infrastructure for dependency, and for content‑heavy teams that trade is usually good. You get the strongest structured‑editing experience of the five options, an official Astro integration, and an export path that keeps the exit honest.

Compare it against the alternatives in the headless CMS comparison for Astro, or start from the headless CMS hub. We build Sanity‑backed Astro sites and migrations to them — that lives under web development.

Screenshots in this series are placeholders — we will replace them with our own, taken on real projects.

Yuri Osipov

Yuri Osipov

Founder, SEO & analytics

Runs Take the Space. Specialises in technical SEO, measurable analytics setups and AI search visibility.

All posts by the author →
Is Sanity a good fit for Astro?
Yes — Sanity ships an official Astro integration that gives you a configured client and an image helper, and its content is structured enough to type properly. The build fetches from the Content Lake API; drafts and visual editing run through a separate preview path.
Do I host Sanity myself?
The Studio can be hosted anywhere, including inside your own app, but the content itself lives in Sanity’s hosted Content Lake. There is no self‑hosted edition of the backend, so the vendor is part of your architecture.
What is GROQ and do I have to learn it?
GROQ is Sanity’s query language, designed for shaped JSON. You can use GraphQL instead, but GROQ is what most of the documentation and the Studio’s preview tooling assume. It reads close to a JSON filter once you have written two or three queries.
How do editors see their changes on the real page?
Sanity’s Presentation tool loads your site in a panel and overlays clickable fields on top of it, so clicking a headline jumps to the matching input. That requires a preview environment that renders drafts, which is a small server‑side route in Astro.
What happens to my content if we leave Sanity?
You can export the whole dataset as NDJSON at any time, including drafts, images and references. Rebuilding the same structure elsewhere is work, but the data is not held hostage.

Want a high‑performance website?

Let’s discuss how we can help your business grow.