Skip to content

Multi-client setup for multi-tenancy with separate studios in Sanity

3repliesLast updated: Nov 13, 2026

Hey Everyone, I’m building a multi tenancy website and I would like to do it with multi clients (sanity/client). I saw the tutorial where we can do it with one client and multi database, however the clients will access they studio and they shouldn’t see each others studio. Is there any way I could do with multi clients?
AI Update

There are two ways to do this:

hidden only changes what a user sees in the Studio. It doesn't control who can read or write the data. Pick based on how strict the isolation has to be and which plan you're on.

Option 1: one Studio, workspaces hidden per user

Pass an array to defineConfig. Each workspace gets its own dataset, name, basePath and schema (Workspaces). Give each one a hidden callback. It receives {currentUser}, and when it returns true the workspace is removed from the workspace menu and chooser. Opening its URL directly shows a not-found screen.

// sanity.config.ts
import {defineConfig} from 'sanity'

const hideUnlessRole = (roleName: string) => ({currentUser}: {currentUser: any}) => {
  // currentUser is null before login; returning true also hides it from unauthenticated users
  if (currentUser === null) return true
  return !currentUser.roles.some((role: {name: string}) => role.name === roleName)
}

export default defineConfig([
  {
    name: 'client-a',
    title: 'Client A',
    basePath: '/client-a',
    projectId: '<projectId>',
    dataset: 'client_a',
    hidden: hideUnlessRole('client-a-editor'),
    // plugins, schema ...
  },
  {
    name: 'client-b',
    title: 'Client B',
    basePath: '/client-b',
    projectId: '<projectId>',
    dataset: 'client_b',
    hidden: hideUnlessRole('client-b-editor'),
    // plugins, schema ...
  },
])

Things to know:

Option 2: a separate project per client

The multi-tenancy guide says multiple projects give complete separation of members and configuration. The trade-offs: you can't reference content across projects, and shared settings have to be duplicated by hand. This is the cleaner choice when each client's editors and frontend are fully separate, and it doesn't depend on Enterprise roles.

You can still keep one codebase and set the project per deployment with environment variables:

// sanity.config.ts
import {defineConfig} from 'sanity'

export default defineConfig({
  projectId: process.env.SANITY_STUDIO_PROJECT_ID!,
  dataset: process.env.SANITY_STUDIO_DATASET || 'production',
  // plugins, schema ...
})

Deploy one Studio per client, either Sanity-hosted or self-hosted. On the frontend, create a @sanity/client instance for each tenant with that tenant's projectId, dataset and an explicit apiVersion.

Which to choose

Show original thread
3 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.

Related contributions