Unlock seamless workflows and faster delivery with our latest releases – get the details

Migrating Custom Auth Providers

You can override the Studio's auth providers with the auth property in v3's defineConfig function. You can use it to disable the default login methods or if your plan supports custom access control, to add a custom login method.

Minimal example

In v2:

// ./config/@sanity/default-login.json
{
  "providers": {
    // Append the custom providers to the default providers or replace them.
    "mode": "append", // default - or 'replace'

    // If true, don't show the choose provider logo screen,
    // automatically redirect to the single provider login
    "redirectOnSingle": false // default

    // The custom provider implementations
    "entries": [
      {
        "name": "vandelay",
        "title": "Vandelay Industries",
        "url": "https://api.vandelay.industries/login",
        "logo": "/static/img/vandelay.svg" // Optional, put it in the studio static folder
      }
    ]
  },

  // Login method to use for the studio the studio. Can be one of:
  // `dual` (default) - attempt to use cookies where possible, falling back to storing authentication token in `localStorage` otherwise
  // `cookie` - explicitly disable `localStorage` method, relying only on cookies
  "loginMethod": "dual"
}

In v3:

// /sanity.config.js (.ts)
import {defineConfig} from 'sanity'

export default defineConfig({
  name: 'default',
  projectId: 'test',
  dataset: 'test',
  auth: {
    redirectOnSingle: false,
    mode: 'append',
    providers: [
      {
        name: 'vandelay',
        title: 'Vandelay Industries',
        url: 'https://api.vandelay.industries/login',
        logo: '/static/img/vandelay.svg'
      }
    ],
    loginMethod: 'dual',
  }
})

Removing a default auth provider

If you want to remove one or two of the default auth providers, you can add the following auth configuration.

// /sanity.config.js (.ts)
import { defineConfig } from 'sanity'

export default defineConfig({
  name: 'default',
  projectId: 'test',
  dataset: 'test',
  auth: {
    redirectOnSingle: false,
    // make `mode` says "replace"
    mode: 'replace',
    providers: [
      {
        name: 'google', 
        title: 'Google', 
        url: 'https://api.sanity.io/v1/auth/login/google'
      },
      /*
      // disable login providers by commenting them out
      {
        name: 'github',
        title: 'GitHub',
        url: 'https://api.sanity.io/v1/auth/login/github'
      },
      {
        name: 'sanity',
        title: 'E-mail / password',
        url: 'https://api.sanity.io/v1/auth/login/sanity',
      }, 
      */
    ],
    loginMethod: 'dual',
  }
})

Feedback or questions?

These guides are under development. If you have questions or suggestions for improvement, then we want to hear from you. Get in touch via our GitHub discussions page.

Was this article helpful?