Watch a live product demo 👀 See how Sanity powers richer commerce experiences

Auth API

The Studio can be configured to use your own login solution rather than the standard ones by supplying the auth provider details in your studio configuration.

Custom authentication can be configured for the studio or individual workspaces. This is done by configuring the root config key auth for the studio or workspace, by using the helper function createAuthStore. Additional details and configurations can be found in the documentation on Migrating Custom Auth Providers.

import {createAuthStore, defineConfig} from 'sanity'

export default defineConfig({
    ..., // The rest of the other studio config.
    auth: createAuthStore({
      projectId: 'dsf3cqw',
      dataset: 'production',
      mode: 'replace',
      redirectOnSingle: false,
      providers: [
        {
          name: 'enterprise-sso',
          title: 'My Enterprise SSO',
          url: 'https://my-enterprise.com/login',
        },
      ],
    }),
  })

Properties

  • REQUIREDprojectIdstring

    The ID for your project

  • REQUIREDdatasetstring

    The name of your dataset

  • modestring

    Value should be either append or replace. Append the custom providers (listed in providers) to the default providers or replace them.

  • redirectOnSingleboolean

    If true, don't show the choose provider logo screen – automatically redirect to the single provider login.

Was this article helpful?