Sanity Studio deployment

How to deploy Sanity Studio, either on your own or using our hosted service.

Using Sanity deploy

Our hosted service will give you a https://<my-studio> URL, and will make deployments super-simple and snappy. To use it, simply type:

sanity deploy

This will build your Studio into a static bundle of files and ship it all to the Sanity API. Hang on for a couple of seconds, and the Studio should be available at https://<my-studio>

If you have not assigned a Studio hostname, you'll be given the option to do so during deploy. If you want to change the hostname later, just run sanity undeploy and then deploy the studio again. You will then be prompted again for a hostname.


The sanity deploy command works by building the source files in your studio project to static files, which is then uploaded and served from your chosen domain.

Note that there's no authentication involved when serving the built source files, so make sure to not include any sensitive data in your studio code (schema files, package.json, config files, custom inputs, etc).

If you want to deploy the studio as part of a continous deployment strategy, you'll want to provide an authorization token using the SANITY_AUTH_TOKEN environment variable. You can create a token that is allowed to deploy studios in the project management dashboard.

Hosting the Studio yourself

The Sanity Studio is a client-side web application. It communicates directly with the Sanity APIs and can in theory be hosted anywhere. The Sanity APIs and data are always hosted by our data store. To host Sanity Studio yourself there are a couple of prerequisites:

  1. The server that delivers the Sanity Studio build assets needs to be configured for single-page application routing. Basically, if the requested URL path doesn't exist on the filesystem, it should serve index.html to allow the frontend router to handle the request.
  2. The domain where the Studio is hosted must be white-listed as a valid domain for the project. The Sanity API ensures that only cross-origin requests with the correct origins are allowed to read and modify data for your project.

If you use our hosting service described above, these things are handled for you.

When hosting yourself you might need to change the base path of the studio from / to a path of your choosing. You can do this by specifying a basePath in the sanity.json file found in the root of your project. This will also change the base path of static files.

"project": {
  "name": "<yourProjectName>",
  "basePath": "/<yourBasePath>"

First, build your Studio to a static bundle of files. Type sanity build within the project directory to do so. This will (by default) output the files to dist/.

Once that's done, set up a server to host the files. There are many ways to do this - Apache and NGINX are general-purpose webservers that can be configured to serve single-page applications with a bit of URL-rewriting.

Another option is to use Node.js to serve the bundle. You'll find a simple example using Node and Express to serve the bundle on GitHub.

Once you've got your Studio hosted somewhere, you just need to add the hostname to the list of allowed origins for your project using (read more on configuring CORS origins here).

You can also build studio in with a continuous integration tool. Add @sanity/cli as a dependency and add the command sanity build as one of the steps.

Was this article helpful?