Firebase Hooksv0.2.0

useEmailLinkSignIn

Passwordless magic-link sign-in, with no window.prompt.

Two steps across two page loads: send the link, then complete the sign-in when the user clicks it.

// Request page
const { sendLink } = useEmailLinkSignIn({
  actionCodeSettings: { url: `${origin}/auth/callback`, handleCodeInApp: true },
});
await sendLink(email);

// Callback page
const { completeSignIn } = useEmailLinkSignIn({ onIdToken: createSession });
const result = await completeSignIn(window.location.href);
if (!result.success && result.needsEmail) showEmailConfirmField();

Returns

sendLink(email) emails the link and remembers the address in localStorage.

completeSignIn(url, email?) resolves to { success: true, user, credential } or a failure result.

Also exposes loading and error.

The stored address won't be there. Rather than calling window.prompt, the result carries needsEmail: true — render your own input and call completeSignIn again with the address.

const result = await completeSignIn(url, confirmedEmail);

Options

Prop

Type

On this page