sanity deploy command builds your Sanity Studio and deploys it to Sanity’s hosting infrastructure. This provides a globally distributed, secure, and fast hosting solution for your Studio.
Basic Usage
--no-build is passed) and deploys it to Sanity hosting.
Syntax
SOURCE_DIR- Optional source directory to deploy (default:./dist)
Options
Build Options
--no-build- Don’t build the Studio prior to deploy, use existingdist/folder--source-maps- Enable source maps for built bundles (increases size)--no-minify- Skip minifying built JavaScript (speeds up build, increases size)
Deployment Options
--external- Register an externally hosted studio (ignores build flags)--schema-required- Fail-fast deployment if schema store fails--verbose- Enable verbose logging-y,--yes- Unattended mode, answers “yes” to all prompts
Examples
Deployment Process
The deployment follows these steps:- Authentication check - Ensures you’re logged in
- Application verification - Checks or creates hosting configuration
- Build Studio (unless
--no-build) - Compiles production bundle - Content verification - Validates the
dist/directory - Create tarball - Packages files for upload
- Upload & deploy - Uploads to Sanity hosting
- Schema extraction - Stores schema for runtime (optional)
Hosting URLs
Your Studio is deployed to:First-Time Deployment
On first deployment, you’ll be prompted for:- Studio hostname - Choose a unique hostname
- Project confirmation - Confirm the project to deploy
App ID Configuration
For auto-updates and consistent deployments, add anappId to your config:
sanity.cli.ts
External Hosting
If you host your Studio elsewhere (Vercel, Netlify, etc.), register it with Sanity:- Skips the build and upload process
- Registers your Studio’s URL with Sanity
- Enables Studio features that require registration
- Optionally deploys schema (unless you skip it)
When using
--external, the --source-maps, --no-minify, and --no-build flags are ignored.Schema Deployment
By default, your schema is extracted and stored during deployment. This enables:- Runtime schema validation
- GraphQL API generation
- Sanity.io features that rely on schema metadata
Require Schema Deployment
Fail the deployment if schema storage fails:- Other services depend on the stored schema
- GraphQL API must stay in sync
- Schema validation is critical
Base Path Deployment
Deploy to a subdirectory:sanity.cli.ts
Environment Variables
Environment variables are embedded at build time:.env.production
Auto-Updates
Enable auto-updates for automatic runtime updates:sanity.cli.ts
- Sanity packages auto-update at runtime
- No rebuild needed for patch updates
- Manually redeploy for major updates
Custom Domains
To use a custom domain:-
Deploy your Studio normally:
- Go to manage.sanity.io
- Select your project
- Navigate to API → Studio Hostname
- Add your custom domain
-
Configure DNS:
- SSL certificates are automatically provisioned
Deployment History
View deployment history in the Sanity management interface:- Go to manage.sanity.io
- Select your project
- Navigate to Deployments
- Deployment timestamps
- Sanity version deployed
- Deploy status
- Rollback options
Rollback
Rollback to a previous deployment:- Go to project deployments in manage.sanity.io
- Find the deployment to restore
- Click Rollback
CI/CD Integration
Deploy from continuous integration:.github/workflows/deploy.yml
Set
SANITY_AUTH_TOKEN in your CI environment. Get a token from manage.sanity.io → API → Tokens.Unattended Mode
For scripts and automation:- Skips all interactive prompts
- Uses defaults for all questions
- Automatically proceeds with deployment
Troubleshooting
Authentication Required
If deployment fails with authentication errors:Build Errors
If the build fails during deployment:-
Test the build locally:
- Fix any errors
-
Deploy again:
Upload Failures
If the upload fails:- Check your internet connection
- Verify you have write access to the project
- Try deploying with verbose logging:
Schema Store Failures
If schema extraction fails but you want to proceed:Large Bundle Size
If deployment is slow due to large bundle:-
Analyze bundle size:
- Remove unused plugins and dependencies
- Optimize images and assets
Alternative Hosting
You can self-host the Studio on:Vercel
Netlify
Custom Server
Next Steps
Manage Projects
Open project management and configure settings
Development Server
Return to local development with the dev server