Skip to content

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

  1. Create an account on Sanity

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

  2. Create a new project

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

  3. 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
  4. 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
  5. 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
  6. Configure the CORS origins

    Go to the project API settings, click on the Add CORS origin button, add the origin of your domain (e.g. https://your-domain.com) 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.

    Sanity CORS

Video tutorial

Further Reading