Sanity
Get a peek at our latest innovations at Sanity Product Day on Dec 8th โ†’

Create a Sanity project

Sanity is a platform for creating and working with structured content. Your content is stored in the cloud and can be distributed anywhere, for example on a website or in an app.

This step will help you create a Sanity project.

Protip

You can follow the video, read the instructions, or do both โ€“ depending on your preferred learning style.

๐Ÿ‘‰ย Look for the pointing finger emoji to quickly locate the actionable steps in the guide if you prefer more action and less explanation.

Step 1: Install Sanity Studio

You start by setting up your content editing environment. Itโ€™s called Sanity Studio, and you can configure and customize it with JavaScript. It runs in the browser. To develop locally, we need to run a development server so you can see your changes instantly.

Gotcha

To install Sanity Studio you'll first need to have node and npm installed.

How to install node and npm?

๐Ÿ‘‰ย To get started, run this in your command line:

npx -y @sanity/cli init --template empty --create-project "Sanity Project" --dataset production
Trouble installing?

I get "Template 'empty' not found"

Your Sanity CLI is out of date and doesnโ€™t have this starter template. To use the latest version, instead run the following command in your shell:

npx -y @sanity/cli@latest init --template empty --create-project "Sanity project" --dataset production

I get "EACCESS: permission denied"

We recommend you reinstall npm with a node version manager by following this guide from from npm.

I get "Failed to communicate with the Sanity API"

Youโ€™re probably logged in with a different account than the one you used to create this project. Use the npx -y @sanity/cli logout command as shown below, as well as making sure your CLI is up to date.

npx @sanity/cli logout && npx -y @sanity/cli init --template empty --create-project "Sanity project" --dataset production

Are you still stuck?

Please describe your problem as detailed as you can in our Slack community. We have a dedicated #getting-started channel to assist you.

This will take you through a setup process by guiding you through the following steps:

  1. ๐Ÿ‘‰ย  Create an account. Select a login provider from the list of options, and confirm with Enter. After creating an account in the browser, come back to the command line window.
  2. ๐Ÿ‘‰ย  Choose an output path. Press Enter to accept the default path, or change it to fit your needs first.
  3. ๐Ÿ‘‰ย  Wait a bit for the installation process to complete. When you get a Success! message, you're good to move on to the next step! ๐ŸŽ‰

Step 2: Run the Studio locally

Having installed the studio in the previous step, itโ€™s time to start it up and run it in your browser!

๐Ÿ‘‰ Enter the Studio's directory:

If you chose a custom output path, remember to change it respectively.

cd sanity-project

๐Ÿ‘‰ Run this command within the Studio's folder:

npx @sanity/cli start

This will build the studio application and start a local development server so you can run the app in your browser. Once the build is complete, you can head over to http://localhost:3333.

You should now see the Sanity Studio running in your browser!

As you modify and save the code, the server will automatically rebuild the studio and refresh the browser.

You can stop your development server by pressing Ctrl-C in the terminal where the server is running.

Summary

At this point, we've set up the following:

  • Sanity account โ€“ you need it to access your projects.
  • Sanity project โ€“ a place for your content represented as documents, stored by Sanity in the cloud. A single Sanity account can have unlimited number of Sanity projects.
  • Sanity Studio โ€“ a React app to edit and publish content. Connected to a Sanity project via APIs. For now, it is installed on your computer. In the next steps, we'll cover how to deploy it to the web and share it with others.

Need help?

Join our Slack community to ask questions and get help!

Join Slack Community

Next: Create a schema โ†’

Was this article helpful?