The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/auth > sendSignInLinkToEmail

sendSignInLinkToEmail() function

Sends a sign-in email link to the user with the specified email.

Signature:

export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;

Parameters

Parameter Type Description
auth Auth
email string The user's email address.
actionCodeSettings ActionCodeSettings The ActionCodeSettings.

Returns:

Promise<void>

Description

The sign-in operation has to always be completed in the app unlike other out of band email actions (password reset and email verifications). This is because, at the end of the flow, the user is expected to be signed in and their Auth state persisted within the app.

To complete sign in with the email link, call signInWithEmailLink() with the email address and the email link supplied in the email sent to the user.

Example

const actionCodeSettings = {
  url: 'https://www.example.com/?email=user@example.com',
  iOS: {
     bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  handleCodeInApp: true
};
await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain emailLink from the user.
if(isSignInWithEmailLink(auth, emailLink)) {
  await signInWithEmailLink('user@example.com', 'user@example.com', emailLink);
}