Sanity Library Reference Docs
    Preparing search index...

    Interface AuthConfig

    Configuration options for creating an auth store.

    interface AuthConfig {
        apiHost?: string;
        callbackUrl?: string;
        clientFactory?: (config: ClientConfig$1) => SanityClient$1;
        initialLocationHref?: string;
        oauth?: { clientId: string; organizationId?: string; redirectUri: string };
        providers?:
            | AuthProvider[]
            | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>);
        storageArea?: Storage;
        token?: string;
    }
    Index

    Properties

    apiHost?: string

    The API hostname for requests. Usually leave this undefined, but it can be set if using a custom domain or CNAME for the API endpoint.

    callbackUrl?: string

    A callback URL for your application. If none is provided, the auth API will redirect back to the current location (location.href). When handling callbacks, this URL's pathname is checked to ensure it matches the callback.

    clientFactory?: (config: ClientConfig$1) => SanityClient$1

    Factory function to create a SanityClient instance. Defaults to the standard Sanity client factory if not provided.

    initialLocationHref?: string

    The initial location href to use when handling auth callbacks. Defaults to the current window location if available.

    oauth?: { clientId: string; organizationId?: string; redirectUri: string }

    Type declaration

    • clientId: string

      Opaque OAuth client_id.

    • OptionalorganizationId?: string

      Organisation id used for RFC 8707 resource scoping. Optional: when omitted, the resource parameter is left off the authorize and token requests, so the issued tokens are not restricted to a single organisation.

    • redirectUri: string

      The redirect URI registered for this client. The OAuth provider redirects back here with the authorization code and state.

    providers?:
        | AuthProvider[]
        | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>)

    Custom authentication providers to use instead of or in addition to the default ones. Can be an array of providers or a function that takes the default providers and returns a modified array or a Promise resolving to one.

    storageArea?: Storage

    Storage implementation to persist authentication state. Defaults to localStorage if available.

    token?: string

    A static authentication token to use instead of handling the OAuth flow. When provided, the auth store will remain in a logged-in state with this token, ignoring any storage or callback handling.