API Reference
Core Functions
getReclaimAuth
function getReclaimAuth(
clientId: string,
cliendSecret: string,
redirectUri: string
): ReclaimAuth
Creates or returns the ReclaimAuth instance.
ReclaimAuth Methods
interface ReclaimAuth {
signIn(): Promise<ReclaimUser>;
signOut(): Promise<void>;
getCurrentUser(): ReclaimUser | null;
onAuthStateChanged(callback: (user: ReclaimUser | null) => void): () => void;
}
Types
ReclaimUser
interface ReclaimUser {
id: string;
userData: {
[key: string]: string;
}
additionalData: {
[key: string]: string;
}[];
}
AuthError
interface AuthError extends Error {
code?: string;
details?: unknown;
}
Hooks
useReclaimAuth
function useReclaimAuth(): {
user: ReclaimUser | null;
loading: boolean;
error: Error | null;
signIn: () => Promise<void>;
signOut: () => Promise<void>;
getCurrentUser: () => ReclaimUser | null;
}
useAuthState
function useAuthState(): {
user: ReclaimUser | null;
loading: boolean;
}
useAuthActions
function useAuthActions(): {
signIn: () => Promise<void>;
signOut: () => Promise<void>;
}
Components
AuthProvider
function AuthProvider(props: { children: React.ReactNode }): JSX.Element
ProtectedRoute
function ProtectedRoute(props: {
children: React.ReactNode
}): JSX.Element
Error Codes
Code | Description |
---|---|
popup_blocked | Authentication popup was blocked |
unauthorized | Client is not authorized |
invalid_request | Invalid request parameters |
network_error | Network connectivity issues |
auth_cancelled | User cancelled authentication |