Sanity Library Reference Docs
    Preparing search index...

    Interface AuthConfig

    Authentication options

    interface AuthConfig {
        apiHost?: string;
        loginMethod?: LoginMethod;
        providers?:
            | AuthProvider[]
            | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>);
        redirectOnSingle?: boolean;
    }
    Index

    Properties

    apiHost?: string

    The API hostname for requests. Should usually be left undefined, but can be set if using custom cname for API domain.

    loginMethod?: LoginMethod

    Login method to use for 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. May fail due to cookies being treated as third-party cookies in some browsers, thus the default is dual.
    • token - explicitly disable cookies, relying only on localStorage method
    providers?:
        | AuthProvider[]
        | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>)

    Array of authentication providers to use, or a function that takes an array of default authentication providers (fetched from the Sanity API) and should return a new list of providers. This can be used to selectively replace, add or remove providers from the list of choices.

    If a static array of providers is provided it will replace the default providers with the ones specified.

    If not set, the default providers will be used.

    redirectOnSingle?: boolean

    If true, the "Choose login provider" (eg "Google, "GitHub", "E-mail/password") screen will be skipped if only a single provider is configured in the providers array - instead it will redirect unauthenticated users straight to the authentication URL.