Skip to content

How to deploy Sanity Studio (hosted or self-hosted)

npx sanity deploy puts the Studio on *.sanity.studio for free. Set studioHost for unattended deploys, use a deploy token in CI, or host it yourself.

Updated 23 November 2026Tested with
  • sanity 6.24.0
  • Sanity CLI 8.33.0

To put Sanity Studio online, run npx sanity deploy in the Studio folder. It builds the Studio and publishes it at https://<name>.sanity.studio, on Sanity's own hosting, free on every plan. The other option is to host the Studio yourself, inside your Next.js app at /studio or as a static build anywhere. This page covers both, plus the settings that make a deploy run without prompts.

We tested the commands with sanity 6.24.0 (CLI 8.33.0). A real deploy needs to be logged in to a Sanity account with access to the project, so our test went as far as a successful build and the deploy's pre-flight check.

Option 1: Sanity's hosting (sanity deploy)

  1. Step 1: Log in once

    Terminal
    npx sanity login

    This opens a browser. In CI, use a deploy token instead: create one in the project at sanity.io/manage under API, Tokens (a deploy token: it has the deploy grant and needs no write access), and set it as SANITY_AUTH_TOKEN in the CI job's secrets.

  2. Step 2: Set the hostname in sanity.cli.ts

    Without studioHost, the first deploy asks for a name. With it, the deploy runs unattended:

    studio/sanity.cli.tsTypeScript
    import { defineCliConfig } from "sanity/cli" export default defineCliConfig({  api: { projectId: "abc123xy", dataset: "production" },  studioHost: "acme-content", // https://acme-content.sanity.studio  deployment: { autoUpdates: false },})

    The hostname is global across Sanity, so pick something specific. Once taken by your project, it stays yours.

  3. Step 3: Build it locally first

    A build catches schema and import errors before anything is uploaded:

    Terminal
    npx sanity build -y✔ Clean output folder (1ms)✔ Build Sanity Studio (261ms)
  4. Step 4: Deploy

    Terminal
    npx sanity deploy

    --dry-run reports what would be deployed without uploading. It still checks your access: in our test, with a made-up project ID, it built the Studio and then stopped at "This studio can't be deployed", listing the missing permission. That's a useful check before you wire it into CI.

Auto-updates: on or off?

With autoUpdates: true, the hosted Studio loads the latest Sanity version within its major release, without a redeploy. You get fixes for free. Off, the Studio runs exactly the version in your package.json. We ship our templates with it off, because the Studio is part of a tested whole: schema, structure and preview were checked against one version. Turn it on if you'd rather not think about Studio updates.

Option 2: host the Studio yourself

Inside your Next.js app. The next-sanity package has a NextStudio component you render on a catch-all route such as app/studio/[[...tool]]/page.tsx. The Studio then lives at yoursite.com/studio and deploys with the site. The trade-off: the Studio's code becomes part of your app's build, which makes builds slower and your app's dependencies heavier.

As static files anywhere. npx sanity build writes a static dist/ you can put on Cloudflare, Netlify or Vercel like any single-page app. Then register the address so Sanity knows where your Studio lives:

Terminal
npx sanity deploy --external --url https://studio.example.com

Either way, the Studio's address must be an allowed CORS origin with credentials, or it can't log in. Fixing Sanity CORS errors has the exact steps.

Which one we'd pick

For most sites, Sanity's hosting. It's free, it's one command, the Studio deploys separately from your site (so an editor's Studio never breaks because a site build failed) and Sanity's hosting takes care of routing and CORS for its own *.sanity.studio address. If the hosted Studio still shows a CORS error, run npx sanity cors list and add the address yourself. Embed it when editors should find it at your own domain, or when the Presentation tool and the site need to share one origin for your setup.

In our Next.js + Sanity templates

The Studio is its own folder, studio/, next to the site. It reads its project ID from studio/.env (SANITY_STUDIO_PROJECT_ID, SANITY_STUDIO_HOST; Sanity only exposes variables that start with SANITY_STUDIO_), and pnpm studio:deploy from the root runs sanity deploy in it. The README's "Set up Sanity" section takes about ten minutes, including importing the demo content.

Questions

Is Sanity Studio hosting free?

Yes, on every plan including Free. You pay for usage of the project (documents, API requests, assets), not for hosting the Studio.

How do I change the studio URL after deploying?

Change studioHost and deploy again under the new name. Check the project at sanity.io/manage afterwards to see which hosted Studios it lists, and remove the one you no longer use.

Why does sanity deploy say I'm missing a grant?

The account you're logged in with has no deploy rights on that project, or the project ID is wrong. Check projectId in sanity.cli.ts, then your role under Members at sanity.io/manage.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components. They ship in the next UI Pro release; the install command and the contents rail are free.