Sanity Library Reference Docs
    Preparing search index...

    Interface AuthConfig

    Authentication options

    interface AuthConfig {
        apiHost?: string;
        loginMethod?: LoginMethod;
        mode?: "replace" | "append";
        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
    mode?: "replace" | "append"

    Whether to append the providers specified in providers with the default providers from the API, or replace the default providers with the ones specified.

    Use the function form of providers instead for more control

    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, the mode property is taken into account when determining what to do with it - append will append the providers to the default set of providers, while replace 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.