UNPKG

@replyke/react-js

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

34 lines (33 loc) 1.29 kB
export interface UseOAuthSignInReturn { /** Initiate OAuth sign-in / sign-up (unauthenticated). */ initiateOAuth: ({ provider, redirectAfterAuth }: { provider: string; redirectAfterAuth?: string; }) => Promise<void>; /** Link a new OAuth provider to the current authenticated user. */ linkOAuthProvider: ({ provider, redirectAfterAuth }: { provider: string; redirectAfterAuth?: string; }) => Promise<void>; /** Call on the callback page to extract tokens from the URL fragment. */ handleOAuthCallback: () => boolean; isLoading: boolean; error: string | null; } /** * Web-only hook for OAuth sign-in and identity linking. * Uses window.location for redirect-based OAuth flow. * * Usage (sign-in): * const { initiateOAuth, handleOAuthCallback } = useOAuthSignIn(); * await initiateOAuth("google", "https://myapp.com/auth/callback"); * * Usage (link provider to current user): * const { linkOAuthProvider, handleOAuthCallback } = useOAuthSignIn(); * await linkOAuthProvider("github", "https://myapp.com/settings"); * * On the callback page (component mount): * useEffect(() => { handleOAuthCallback(); }, []); */ declare function useOAuthSignIn(): UseOAuthSignInReturn; export default useOAuthSignIn;