Home > @firebase/auth > signInWithEmailLink
signInWithEmailLink() function
Asynchronously signs in using an email and sign-in email link.
Signature:
export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;
Parameters
Parameter | Type | Description |
---|---|---|
auth | Auth | The Auth instance. |
string | The user's email address. | |
emailLink | string | The link sent to the user's email address. |
Returns:
Promise<UserCredential>
Description
If no link is passed, the link is inferred from the current URL.
Fails with an error if the email address is invalid or OTP in email link expires.
Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
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);
}