Let's go through the steps of setting up a Sanity project.
Prerequisites
This tutorial assumes the following:
- You have Node.js installed on your computer. If you don't, you can download it here.
- You have Visual Studio Code installed on your computer. If you don't, you can download it here. (You can use your own IDE of choice, but we'll be specific towards VS Code.)
Creating an Account
Go to sanity.io and press Get started. You will be asked to create an account or log in if you already have an account. You can use your Google, GitHub, or email to create an account.
Note: remember which method you used to create your account, you will need it very soon.
Creating a Project
We're now ready to create our Sanity Project. We will use the Sanity CLI to create a new project. The Sanity CLI is a command-line tool that allows you to create, manage, and deploy Sanity projects.
First, let's go to our Documents folder, where we will create our Sanity project. We can do this by running the following command in our terminal: (you can use any folder you want, we will be using Documents for this tutorial)
cd Documents
Now that we're in Documents, we can create our Sanity project by running the following command:
npm -y create sanity@latest
This will start the Sanity CLI and ask you a few questions. The first question is:
? Login type (Use arrow keys)❯ Google GitHub E-mail / password
Use your arrow keys to select the login method you used to create your Sanity account. Hit enter to select your login method.
Now, we're going to create a new project. Press enter, since we want to create a new project. Press enter again, and the default project name of "My Sanity Project" will be selected.
Login successful? Select project to use (Use arrow keys)? Create new project? Your project name: (My Sanity Project)
Type Y
and hit enter when asked for using the default dataset configuration. Hit enter again, as we're already in our Documents folder.
? Use the default dataset configuration? Y? Project output path: (/Users/username/Documents/my-sanity-project)
Then, when asked for a project template, arrow down to Clean project with no predefined schemas
and hit enter.
? Select project template Movie project (schema + sample data) E-commerce (Shopify) Blog (schema)❯ Clean project with no predefined schemas
Also, we won't be using TypeScript, so we can type n when asked if we want to use TypeScript. We'll also be using npm
as our package manager rather than using our own manual package manager.
? Do you want to use TypeScript? n? Package manager to use for installing dependencies?❯ npm manual
If you see Success!
in your terminal, then you have successfully created your Sanity project.