AuthProvider
Authentication state management and hooks.
Props
Prop | Type | Default | Description |
---|---|---|---|
children | string | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | The children to render | |
onAuthStateChange | (
callback: AuthStateChangeCallback<TUser>,
) => UnsubscribeHandler | Should trigger whenever the authentication state changes | |
onGetToken | () => Promise<AuthToken> | Return the session token | |
onLoadUser | () => Promise<TUser | null> | Loads user data after authentication | |
onLogin | (
params: AuthParams,
options?: AuthOptions<ExtraAuthOptions> | undefined,
) => Promise<TUser | null | undefined> | The login method | |
onLogout | (
options?: AuthOptions<ExtraAuthOptions> | undefined,
) => Promise<unknown> | The logout method | |
onResetPassword | (
params: Required<Pick<AuthParams, "email">>,
options?: AuthOptions<ExtraAuthOptions> | undefined,
) => Promise<any> | Request to reset a password. | |
onRestoreAuthState | () => Promise<void> | Restore the authentication state, eg after redirecting | |
onSignup | (
params: AuthParams,
options?: AuthOptions<ExtraAuthOptions> | undefined,
) => Promise<TUser | null | undefined> | The signup method | |
onUpdatePassword | (params: Required<Pick<AuthParams, "password">>, options?: AuthOptions<ExtraAuthOptions> | undefined) => Promise<...> | Update the password. | |
onVerifyOtp | (
params: OtpParams,
options?: AuthOptions<ExtraAuthOptions> | undefined,
) => Promise<boolean | null | undefined> | Verify an one time password (2fa) | |
refetchUserOnWindowFocus | boolean | Refetch the user data when the window regains focus |
Was this helpful?