✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.

OAuth ReactJS
API Reference

API Reference

Core Functions

getReclaimAuth

function getReclaimAuth(
  clientId: 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;
  data: {
    [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

CodeDescription
popup_blockedAuthentication popup was blocked
unauthorizedClient is not authorized
invalid_requestInvalid request parameters
network_errorNetwork connectivity issues
auth_cancelledUser cancelled authentication