Can a deployed Sanity Studio switch between datasets via URL parameter?

3 replies
Last updated: Mar 8, 2024
Quick Question: If you have a deployed studio (e.g. https://the-jump-student-portal.sanity.studio/ ) can you make that studio switch between data sets? Like is there a parameter you can add to the URL? Or is it in the settings of that studio page somewhere?
AI Update

Yes! When you have multiple workspaces configured in your Sanity Studio, you can switch between them using the URL basePath parameter. Here's how it works:

Switching Between Workspaces via URL

If you've configured multiple workspaces in your Studio, each workspace must have a unique basePath defined in your sanity.config.ts file. You can then navigate directly to different workspaces by appending the basePath to your Studio URL.

For example, if you have workspaces configured like this:

export default defineConfig([
  {
    name: 'production-workspace',
    basePath: '/production',
    dataset: 'production',
    // ... other config
  },
  {
    name: 'staging-workspace',
    basePath: '/staging',
    dataset: 'staging',
    // ... other config
  }
])

You would access them at:

  • https://the-jump-student-portal.sanity.studio/production
  • https://the-jump-student-portal.sanity.studio/staging

Switching Within the Studio

When you have multiple workspaces configured, Sanity Studio automatically displays a dropdown menu in the top left corner that lets you switch between workspaces without changing the URL manually.

Important Notes

  • Each workspace configuration requires its own name, basePath, projectId, and dataset properties
  • The basePath acts as a URL parameter that routes to the specific workspace
  • All workspaces share the same codebase but can have different datasets, schemas, tools, and plugins
  • If you only have a single workspace, you don't need to specify name or basePath

This workspace feature is particularly useful for managing multiple environments (development, staging, production) or separating content for different brands, regions, or teams within the same Studio instance.

Show original thread
3 replies
You want to take a look at workspaces
user K
Amazing! TY! πŸ™‚

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?