useAuthContext
A custom hook that provides the authentication context based on the specified authentication step type. It ensures that the hook is used within an AuthModalProvider
and throws an error if the context is not available or if the current auth step type does not match the expected type.
Import
Usage
import { function useAuthContext<TType extends AuthStep["type"] | undefined = "email_verify" | "otp_verify" | "totp_verify" | "passkey_verify" | "passkey_create" | "passkey_create_success" | "email_completing" | ... 6 more ... | undefined>(type?: TType): AuthContextType<...>useAuthContext } from "@account-kit/react";
const { const authStep: AuthStepauthStep } = useAuthContext<"email_verify" | "otp_verify" | "totp_verify" | "passkey_verify" | "passkey_create" | "passkey_create_success" | "email_completing" | "oauth_completing" | "initial" | ... 4 more ... | undefined>(type?: "email_verify" | ... 12 more ... | undefined): {
...;
} | ... 12 more ... | {
...;
}useAuthContext();
Parameters
type
AuthStep["type"]
Optional type of authentication step to validate against the current context
Returns
AuthContextType
The authentication context for the current component