In this guide, you will learn how to get started with a project on Sanity.io from the command-line interface. It will walk you through installing the necessary tooling, initiating a project, and starting the local development server for Sanity Studio. You will also learn how to deploy it on sanity.studio, and how to invite collaborators to the project.
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.
To get started with a new project, run this command after you have installed the CLI tool:
This will log you into 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.
To start the development server for Sanity Studio, run this command within the studio folder:
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.
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 following command will build your studio to a static bundle and deploy it on a pretty
When you change something in the Studio locally, you can rerun this command to deploy the latest 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
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.
Once your studio is deployed, you can invite collaborators to your project.
sanity users invite firstname.lastname@example.org
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 manage.sanity.io.