RefirebaseRefirebase

linkProvider

Link the current account with an additional third-party provider.

Usage

The linkProvider method allows a user to sign in with multiple providers by linking them to their current account.

LinkGithub.tsx
import { useRefirebase } from 'refirebase/react';

export function LinkGithub() {
  const { auth } = useRefirebase();

  const handleLink = async () => {
    const { data, error } = await auth.linkProvider('github');
    if (error) console.error(error);
    else console.log('Linked credentials:', data);
  };

  return <button onClick={handleLink}>Link GitHub Account</button>;
}

Parameters

ParamTypeDescription
provider*'google' | 'github' | 'twitter' | 'facebook'The third-party provider to link.

Return value

Returns

Promise<{ data: UserCredential | null, error?: ReturnType<typeof toRefirebaseError> }>

Returns the linked user credentials on success, or an error if linking fails.