Getting started with Sanity CLI

How to get started with using the command-line interface (CLI).

In this guide you will learn how to get started with a project on from the command-line interface. It will walk you through installing the necessary tooling, initiating a project, and start the local development server for Sanity Studio. You will also learn how to deploy it on, and how to invite collaborators to the project.

Install CLI tooling

Don't have Node and npm installed? No problem, we have instructions.

npm install -g @sanity/cli

The command line tool is used to set up new projects, manage datasets, import data, and much more. We'll be using it to get your project up and running. You can always run sanity help to get an overview of the commands you have available. Note that you will have more commands available within a studio folder.

Bootstrap a project

To get started with a new project, run this command after you have installed the CLI tool:

sanity init

This will log you in to Sanity, create a project, set up a dataset, and generate the files needed to run the editing environment locally.

Sanity Studio has pretty much all logic and code is contained in NPM packages. This makes it really easy to upgrade to new versions, and to install and ship plugins as self-contained packages.

Run the studio

To start the development server for Sanity Studio, run this command within the studio folder:

sanity start

This builds the initial JavaScript code required to run the studio, and starts a local web server. As you modify and save the code, the server will automatically rebuild the studio and refresh the browser.

The studio is just an HTML file and some JavaScript bundles that run in your browser. It talks to the Sanity API which stores your data and lets you query it from whatever platform or front-end you want.

Edit the schema

Open the studio folder in your code editor, and locate the schema.js file in the schemas folder. The schema defines your content models. We recommend that you start by modelling your content logically, without thinking too much about how it's going to be presented. We've written about why this often makes a lot of sense.

Schemas are a pretty big topic. For now, you can just take a quick look at how the schema is defined, and move on to the next step.

Deploy the studio

You can host the studio wherever you like, but we've made it easy for you to get started by deploying it to our cloud platform. Running the sanity deploy command will build your studio to a static bundle and deploy it on a pretty <your-project> URL. If you change something in the studio locally, this is also how you would upload new changes.


We recommend checking the studio files into git. While it's technically possible to derive your schemas back from the compiled studio, you'll save yourself some time and headache with having it in git and pushed to a remote repository.

Our API requires that you define what origins should be allowed to query the API. It's taken care of when you deploy to our servers, but if you host the project yourself you'll need to set up which origins to allow in the Sanity project dashboard.


Do you need to change the subdomain for <yourName> Run sanity undeploy to remove the studio from its current domain. When you run sanity deploy again, you will be prompted to set a new subdomain.

Invite collaborators

Once your studio is deployed, you can invite collaborators to your project.

sanity users invite

Enter the email address you want to send the invitation to, and choose the privileges you want to give them (administrator, read+write, read). They will get an invitation with a link that lets them log in with a Google or GitHub account. They can also choose to create a new account with email and password.


You can also invite collaborators from your project’s settings on

What's next?

To continue learning more about Sanity and the Studio, a good next step is to familiarize yourself with datasets and content modelling.

Was this article helpful?