Skip to content
Artizan Templates
Language: English
Custom website
Menu

Connect Sanity

Create your own Sanity project, load the sample content and open Studio. One setup command does most of the work.

Log in to Sanity

Terminal
        pnpm --filter studio exec sanity login
      

This opens your browser. Sign in, or create a Sanity account.

Run the setup command

Terminal
        pnpm sanity:setup
      

The command asks a few questions, then:

  • creates a Sanity project and dataset, or connects to one you already have
  • creates the API tokens and the webhook secret
  • adds the CORS origins the site and Studio need
  • deploys the content schema
  • writes your .env files

Tokens are written only to .env files, which are not committed to Git.

To skip the questions:

Terminal
        pnpm sanity:setup --create "Your Business"
pnpm sanity:setup --project abc12345 --dataset production
      

The first line creates a new project. The second connects an existing one; replace abc12345 with your project ID.

Load the sample content (optional)

Terminal
        pnpm sanity:seed
      

This copies the template's sample content into your dataset. It only adds documents that don't exist yet and never overwrites your changes. Skip it if you'd rather start empty.

Open Studio

Terminal
        pnpm dev:studio
      

Studio runs at http://localhost:3333 and the site at http://localhost:4321. To start both at once, run pnpm dev:all. The site now reads its content from your Sanity project.

When you know your domain

Run the setup again with your production address, so Sanity accepts requests from it:

Terminal
        pnpm sanity:setup --project abc12345 --site-url https://example.com
      

Next

Content & Studio: replace the sample content with your own.