Skip to content
@sanity-io

Sanity

A fully customizable all-code backend for content-driven websites and apps. Get started for free.
Sanity

Sanity - Content Operating System

npm npm downloads Discord MIT License


Sanity is the Content Operating System for the AI era. Model your content as code, store it in a real-time API, and use it everywhere: websites, mobile apps, agentic applications, and the editorial workflows in between.

Quick Links

🚀 Get started • 📚 Documentation • 💬 Community • 🎓 Learn • 📦 Exchange

Why Developers Choose Sanity

  • Content Lake: Real-time database for structured content. Query with GROQ, or access it over HTTP from any language.
  • Schema-as-code: Define content models in TypeScript, version control them, and get automatic type generation for queries and documents.
  • Real-time and collaborative: Live queries, multiplayer editing, and instant previews are part of the platform.
  • Studio + App SDK: A customizable React-based editorial environment, plus an SDK with hooks and stores for building custom content apps on top of Sanity.
  • AI agents and content automation: The MCP server lets Claude, Cursor, and VS Code read and edit your content with full schema context. Agent Actions generate, transform, and translate content with LLMs. Canvas turns free-form drafts into structured documents.
  • Functions: Serverless logic that runs on content changes. No infrastructure to maintain.
  • Framework agnostic: Works with Next.js, Astro, Nuxt, React Router, SvelteKit, or any framework.
See code examples

Schema-as-code

// schemaTypes/articleType.ts
import { defineType, defineField } from "sanity";

export const articleType = defineType({
  name: "article",
  type: "document",
  fields: [
    defineField({
      name: "title",
      type: "string",
      validation: (Rule) => [
        Rule.required(),
        Rule.max(80).warning(
          "Titles over 80 characters may be truncated in search results"
        ),
      ],
    }),
    defineField({
      name: "excerpt",
      type: "text",
      validation: (Rule) =>
        Rule.custom((value, context) => {
          // Cross-field validation
          const isFeatured = context.document?.featured;
          return isFeatured && !value
            ? "Featured articles need an excerpt"
            : true;
        }),
    }),
  ],
});

GROQ query language

import { defineQuery } from "groq";

export const ARTICLES_QUERY = defineQuery(`*[_type == "article"] {
  _id,
  title,
  "author": author->name,
  "categories": categories[]->title,
  "wordCount": length(pt::text(body))
}[0...10]`);

GraphQL is also available if you prefer it.

Getting Started

npm create sanity@latest

This creates a Sanity project with Studio and connects you to the Content Lake. You'll get:

  • A customizable content management interface
  • Real-time APIs for your content
  • Automatic TypeScript types
  • Generous free tier with hosting and bandwidth included (no credit card required)

Pricing: Start free, pay-as-you-go for overages. View pricing →

Trusted By

Sanity powers content operations for teams at Spotify, Shopify, Figma, Unity, Linear, Anthropic, MoMA, Brex, Arc'teryx, Tecovas, and thousands more.

Community & Resources

Key Repositories

  • sanity: Core toolkit, Studio, and CLI
  • sdk: App SDK for building custom content applications on top of Sanity
  • next-sanity: Sanity toolkit for Next.js
  • agent-toolkit: Building blocks for AI agents working with Sanity content
  • visual-editing: Tools for live visual editing
  • GROQ: Specification for the GROQ query language
  • groq-js: JavaScript implementation of GROQ
  • document-internationalization: Plugin for translating documents across languages

Contributing

We welcome contributions to our open source projects. Check each repository's CONTRIBUTING.md for guidelines, or report bugs in the relevant issue tracker.


Built by developers, for developers. We treat content as a strategic asset and give technical teams the tools to work without constraints.

Pinned Loading

  1. sanity sanity Public

    Sanity Studio – Rapidly configure content workspaces powered by structured content

    TypeScript 6.4k 557

  2. GROQ GROQ Public

    Specification for GROQ - The Query Language for JSON

    JavaScript 451 18

  3. next-sanity next-sanity Public

    Sanity toolkit for Next.js

    TypeScript 956 111

  4. litter litter Public

    Litter is a pretty printer library for Go data structures to aid in debugging and testing.

    Go 1.7k 61

  5. groq-js groq-js Public

    JavaScript implementation of GROQ, the query language for JSON

    TypeScript 345 26

  6. mendoza mendoza Public

    Differ for structured documents (JSON)

    Go 277 6

Repositories

Showing 10 of 367 repositories
  • cli Public

    Sanity command line tool (CLI)

    sanity-io/cli's past year of commit activity
    TypeScript 9 MIT 4 31 46 Updated Oct 17, 2026
  • sanity Public

    Sanity Studio – Rapidly configure content workspaces powered by structured content

    sanity-io/sanity's past year of commit activity
    TypeScript 6,363 MIT 557 74 235 Updated Oct 17, 2026
  • get-it Public

    Composable HTTP request library for node and browsers

    sanity-io/get-it's past year of commit activity
    TypeScript 38 MIT 8 1 4 Updated Oct 17, 2026
  • eslint-config-studio Public

    The ESLint configuration that ships with new Sanity Studio projects. Designed to be relatively unobtrusive to help find bugs instead enforce opinions.

    sanity-io/eslint-config-studio's past year of commit activity
    JavaScript 8 MIT 3 2 11 Updated Oct 17, 2026
  • renovate-config Public

    Composable configuration presets for @renovateapp curated by Sanity

    sanity-io/renovate-config's past year of commit activity
    JavaScript 10 MIT 1 1 6 Updated Oct 17, 2026
  • context Public

    Tools for building AI agents with structured access to Sanity content

    sanity-io/context's past year of commit activity
    TypeScript 7 1 2 10 Updated Oct 17, 2026
  • client Public

    JavaScript client for retrieving, creating and patching data from Sanity.io

    sanity-io/client's past year of commit activity
    TypeScript 114 MIT 35 21 18 Updated Oct 17, 2026
  • demo-graphql-presentation-nextjs Public template

    Sanity Presentation + GraphQL (URQL) + Next.js (both App Router and Pages Router) = ❤

    sanity-io/demo-graphql-presentation-nextjs's past year of commit activity
    TypeScript 7 1 1 20 Updated Oct 17, 2026
  • id-utils Public

    Utilities for working with Sanity document IDs with added validation and type safety.

    sanity-io/id-utils's past year of commit activity
    TypeScript 7 MIT 0 1 11 Updated Oct 17, 2026
  • template-nextjs-personal-website Public template

    A Next.js Personal Website with a Native Authoring Experience

    sanity-io/template-nextjs-personal-website's past year of commit activity
    TypeScript 302 68 4 6 Updated Oct 17, 2026