Setting up a new project and dataset in Sanity.io using a specific command.
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 projectsanity dataset create <name> --visibility private- Create with specific visibility
Your best options:
Use
sanity initwith minimal interaction - What you're already doing. Runsanity init, create the project and dataset when prompted, then cancel. It's not elegant, but it works.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.Use
sanity dataset createafter project exists - If you already have a project ID (from the Dashboard or a previous init), you can configure yoursanity.cli.jsorsanity.config.jswith that project ID, then runsanity 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!
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.