Mkdirs Docs

Sanity

How to configure the Sanity.

Mkdirs uses Sanity as a headless CMS, so you can manage the content of the website (including user data, items data, blog posts data, images, etc.) through Sanity Studio, and you don't need to configure the database or the storage anymore.

Configuration

Create an account on Sanity

If you don't have an account on Sanity, follow their steps to signup.

Create a new project

After signin on Sanity, you can create your project here.

Get the project id

After creating the project, you will see the project id under the project name.

# .env
# [required]
NEXT_PUBLIC_SANITY_PROJECT_ID=your_project_id

Get the dataset

The default dataset is production, and you can use the default dataset or create a new one.

# .env
# [required]
NEXT_PUBLIC_SANITY_DATASET=your_dataset

If you want to separate the production and development environments, you can create a new dataset for the development environment, and set different datasets for the production and development environments.

Get the API token

Go to the project API settings, click on the Add API token button, create a new token with the permissions of Editor, and set it to the .env file.

# .env
# [required]
SANITY_API_TOKEN=your_api_token

Configure the CORS origins

Go to the project API settings, click on the Add CORS origin button, add the origin of your domain, for example, https://your-domain.com for production or http://localhost:3000 for local development.

It's used to allow you to access the Sanity Studio under the /studio path, for example, https://your-domain.com/studio or http://localhost:3000/studio.

Make sure you add the origin of your domain to the CORS origins, otherwise you will not be able to access the Sanity Studio (aka, the CMS or the backend of the website).

Sanity CORS

Video tutorial

Further Reading

Last updated on

On this page