Different ways to initialize a Sanity project: npm create vs sanity init
I'm currently working through the Sanity Documentation to get Sanity up and running but I've discovered several ways to do this and I'm finding it confusing. For instance, in the section
Getting Started, the following commands are used:
npm create sanity@latest -- --template clean --create-project "Sanity Project" --dataset productionnpm run dev
then in the section
Setting up with Sanity, these commands:
npm install -g @sanity/cli
sanity init
sanity start
and the video tutorial:
npm create sanity@latest
I was wondering if anyone could help me to gain some clarity with this and explain the differences between the approaches?
Please forgive me if this question seems really simple
😳
Thanks!
Great question! This can definitely be confusing for newcomers. Let me break down the different approaches you've found:
The Modern Way (Recommended): npm create sanity@latest
This is the current, recommended approach for starting new Sanity projects. The npm create sanity@latest command:
- Doesn't require global CLI installation
- Walks you through an interactive setup
- Automatically installs dependencies
- Sets up your project with modern defaults
- Uses
npm run devto start the development server
The command you found with all the flags (--template clean --create-project "Sanity Project" --dataset production) is just the non-interactive version of this same approach, where you specify everything upfront instead of answering prompts.
The Legacy Way: npm install -g @sanity/cli + sanity init
This is the older approach that involves:
- Installing the Sanity CLI globally
- Running
sanity initto set up your project - Using
sanity startto run the development server
While this still works, it's considered the legacy method. The main differences:
sanity startis the old command for running the dev serversanity dev(ornpm run dev) is the modern equivalent used with Studio v3+, with better performance and Vite-powered live reloading
What You Should Use
Go with npm create sanity@latest - it's simpler, doesn't pollute your global npm packages, and follows modern JavaScript tooling conventions. After setup, you'll use npm run dev to start your Studio at http://localhost:3333.
The documentation showing different approaches likely reflects different versions or specific use cases. The video tutorial showing just npm create sanity@latest (without flags) is the most beginner-friendly - it'll walk you through everything interactively.
No need to feel embarrassed - Sanity's documentation does show multiple paths, and it's totally reasonable to be confused when you're just starting out! 😊
Show original thread3 replies
Was this answer helpful?
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.