Setting up a new project and dataset in Sanity.io using a specific command.

3 replies
Last updated: Mar 21, 2024
I was setting up a new project the other day, I didn’t need to do the entire
init
setup, just the Add a new project and dataset.
Is there a command just to set the Project and dataset up? I found going though
init
and cancelling after I created those 2 parts worked, but felt wrong?
AI Update

You're absolutely right—running sanity init and then cancelling after creating the project and dataset does feel like a workaround! Unfortunately, there isn't a single dedicated command to only create a project and dataset without going through the full init flow.

Based on the Sanity CLI documentation, the available commands are:

For projects:

  • sanity projects list - Lists projects connected to your user

That's it for the projects command—there's no sanity projects create command available.

For datasets: From the sanity dataset command, you can:

  • sanity dataset create [NAME] - Create a new dataset within your project
  • sanity dataset create <name> --visibility private - Create with specific visibility

Your best options:

  1. Use sanity init with minimal interaction - What you're already doing. Run sanity init, create the project and dataset when prompted, then cancel. It's not elegant, but it works.

  2. Create the project via the Dashboard - You can create projects through the Sanity Dashboard web interface, then use sanity dataset create <name> from the CLI to add datasets to that project.

  3. Use sanity dataset create after project exists - If you already have a project ID (from the Dashboard or a previous init), you can configure your sanity.cli.js or sanity.config.js with that project ID, then run sanity dataset create <dataset-name> to add new datasets.

The Sanity CLI is primarily designed around the init workflow for project setup, so there isn't currently a streamlined "create project only" command. Your approach of using init and cancelling is actually a reasonable workaround given the current CLI design!

npx sanity init --bare
should do it!
Nice, thanks. I’ll give that a try, that lets you create a project, name it then set the production dataset?
Amazing, just what I needed!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?