How to create a new project without creating all the studio files in Sanity.io.

2 replies
Last updated: Nov 2, 2023
Hey Everyone,
Is there a way to create a new project without creating all the studio files?

It could be on CLI or web UI, what I am looking to achieve is to build my own starter kit that would be private and would contain studio with schemas and also a web app with basics, and I would only need to create a new project to link the project ID and dataset.
AI Update

Yes! You have a couple of options to create a new Sanity project without initializing all the studio files locally. This is perfect for your use case where you want to maintain your own private starter kit.

You can programmatically create projects using the Management API. This creates just the project in Sanity's system without any local files:

curl -X POST https://api.sanity.io/v2021-06-07/projects \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "My New Project",
    "organizationId": "org_abc123"
  }'

This returns a project ID and details, which you can then reference in your custom starter kit's configuration files.

Option 2: Use CLI flags to minimize scaffolding

While sanity init typically creates studio files, you can use the --create-project flag to create a project and control what gets initialized:

sanity init \
  --create-project "My Project" \
  --organization org_abc123 \
  --dataset production \
  --output-path ./studio \
  -y

You can then discard the generated files and use your own starter kit instead.

  1. Create the project using the Management API (just the project, no files)
  2. Store the project ID returned from the API
  3. Clone your private starter kit repository
  4. Update the configuration in your starter kit with the new project ID and dataset name (typically in sanity.config.ts or sanity.cli.ts)
  5. Run your setup - your starter kit already has the schemas and structure you need

This way, you maintain full control over your starter kit structure while still creating properly configured Sanity projects. The Management API approach is cleaner since it doesn't create any local files you'd need to discard.

If you’re on the latest version of the CLI, running
sanity init
inside of an existing code base should create a new project without bootstrapping a Studio.
That's perfect, figured it out after doing some tests, thanks for that!
By the way, apologies for posting this same question on two channels, wasn't sure what was the best one for it as it's sort of a basic one.

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?