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
- Sanity is a hosted content platform, not a CMS you install: the Content Lake stores content, the Studio edits it.
- Schema lives in TypeScript, so fields, validation and previews are code you review.
- GROQ shapes responses on the server; GraphQL is available if your team prefers it.
- The official
@sanity/astrointegration gives you a configured client and an image helper in a few lines. - Real‑time collaboration and visual editing are the strongest reasons to choose it — and the vendor dependency is the main reason not to.
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
- Content teams of five or more, editing in parallel and publishing daily.
- Multilingual sites where translation happens per field, not per page.
- Editorial products — magazines, knowledge bases, documentation — where content outlives any single design.
- Teams without a DevOps function, who would rather pay a vendor than run a database.
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
- Structure that holds. References, arrays of blocks and typed objects survive redesigns.
- Real‑time. Two editors on the same document see each other’s changes; presence is visible.
- Portable Text. Rich text is a JSON array, so you render your own components rather than inheriting HTML.
- Asset pipeline. Transformations, focal points and CDN delivery without extra services.
- Studio freedom. The editing UI is React — you can add custom inputs, dashboards and validations.
Weaknesses
- Hosted only. No self‑hosted backend; your content sits in a vendor’s cloud.
- Two systems to deploy. The Studio is a separate app with its own build and hosting, even if it is small.
- GROQ is another language. Small cost, real cost — new developers need a day, not a month.
- Pricing follows usage and seats. It is comfortable at the start and worth modelling before a newsroom of thirty editors arrives.
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
Founder, SEO & analytics
Runs Take the Space. Specialises in technical SEO, measurable analytics setups and AI search visibility.