Skip to main content
The Sanity CLI is a powerful command-line tool for creating, developing, building, and deploying Sanity Studio projects. It provides commands for project initialization, local development, production builds, authentication, and project management.

Installation

The Sanity CLI comes bundled with the sanity package:
npm install sanity
For global installation:
npm install -g sanity

Getting Started

Create a new Sanity project:
npm create sanity@latest
This is the recommended way to initialize a new Sanity Studio project.

Available Commands

The Sanity CLI provides the following commands:

Core Commands

  • sanity init - Initialize a new Sanity Studio and/or project
  • sanity dev - Start a local development server with live reloading
  • sanity build - Build the Studio into a static bundle for production
  • sanity deploy - Build and deploy Studio to Sanity hosting

Authentication

  • sanity login - Authenticate the CLI for access to Sanity projects
  • sanity logout - Log out from the current user session

Project Management

  • sanity manage - Open project management interface in browser
  • sanity projects list - List all projects you have access to
  • sanity projects create - Create a new project

Documentation

  • sanity docs browse - Open Sanity documentation in browser
  • sanity docs search - Search the Sanity documentation
  • sanity docs read - Read documentation in the terminal

Development Tools

  • sanity install - Install a Sanity plugin
  • sanity debug - Gather information for debugging purposes
  • sanity versions - Show installed versions of Sanity packages
  • sanity typegen generate - Generate TypeScript types from schema

Advanced Commands

  • sanity codemod - Run codemods to transform your code
  • sanity functions - Manage Sanity Functions (dev, test, logs, env)
  • sanity blueprints - Manage infrastructure blueprints
  • sanity openapi - Interact with OpenAPI specifications
  • sanity telemetry - Manage telemetry settings
  • sanity mcp configure - Configure AI editor integration (MCP)

Getting Help

Display help for any command:
sanity help
sanity help <command>
For example:
sanity help dev

Common Usage Patterns

npm create sanity@latest

Configuration

The CLI reads configuration from:
  • sanity.cli.ts or sanity.cli.js - CLI-specific configuration
  • sanity.config.ts or sanity.config.js - Studio configuration
Use sanity.cli.ts to configure API settings, project ID, dataset, and build options.

Environment Variables

The CLI respects several environment variables:
  • SANITY_STUDIO_PROJECT_ID - Override project ID
  • SANITY_STUDIO_DATASET - Override dataset
  • SANITY_AUTH_TOKEN - Authenticate without interactive login

Next Steps

Initialize Project

Learn how to create a new Sanity project

Development Server

Start developing with the local dev server

Build for Production

Create production-ready static bundles

Deploy Studio

Deploy your Studio to Sanity hosting

Build docs developers (and LLMs) love