How to send email verification link with firebase using ReactJS?
Last Updated :
26 Jul, 2024
Email verification is a crucial step in user authentication and account security. It ensures that users provide a valid email address and allows you to verify their identity before granting them access to certain features or functionalities. Firebase, a powerful platform for building web and mobile applications, provides a simple and effective way to send email verification links.
Prerequisites
Approach
To send email verification links with Firebase using React JS we will install the npm Firebase module and configure it with the React project. Add the configuration details like API key, domain, project ID, etc in the auth method inside the Firebase configuration file and start the project.
Steps to Set Up firebase with react.
Creating React Application
Step 1: Create a React myapp using the following command.
npx create-react-app myapp
Step 2: After creating your project folder i.e. myapp, move to it using the following command.
cd myapp
Step 3: After creating the ReactJS application, Install the firebase module using the following command.
npm install [email protected] --save
Project structure
The project structure will look like this.

Dependencies list after installing libraries.
{
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"firebase": "^8.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
}
Step 4: Go to your firebase dashboard and create a new project and copy your credentials.
const firebaseConfig = {
apiKey: "your api key",
authDomain: "your credentials",
projectId: "your credentials",
storageBucket: "your credentials",
messagingSenderId: "your credentials",
appId: "your credentials"
};
Step 5: Now Enable the sign in with email and password from your sign-in method.

Example: This example involves a basic react form and firebase configuration to send the verification link with firebase in react.
JavaScript
// Filename - App.js
import auth from "./firebase";
import "./App.css";
import { useState } from "react";
function App() {
const [email, setemail] = useState("");
const [password, setpassword] = useState("");
const signup = () => {
auth.createUserWithEmailAndPassword(email, password)
.then((userCredential) => {
// send verification mail.
userCredential.user.sendEmailVerification();
auth.signOut();
alert("Email sent");
})
.catch(alert);
};
return (
<div className="App">
<br />
<br />
<input
type="email"
placeholder="Email"
onChange={(e) => {
setemail(e.target.value);
}}
></input>
<br />
<br />
<input
type="password"
placeholder="password"
onChange={(e) => {
setpassword(e.target.value);
}}
></input>
<br />
<br />
<button onClick={signup}>Sign-up</button>
</div>
);
}
export default App;
JavaScript
// Filename - firebase.js
import firebase from "firebase";
const firebaseConfig = {
// Your credentials
};
firebase.initializeApp(firebaseConfig);
var auth = firebase.auth();
export default auth;
Steps to run the application: Run this command in the terminal in Project directory.
npm start
Output: Here, When you click on sign-up button the verification email is sent to the provided email address.
Here is the verification mail.

Similar Reads
How to upload files in firebase storage using ReactJS ? Firebase Storage is a powerful cloud storage solution provided by Google's Firebase platform. It allows developers to store and retrieve user-generated content, such as images, videos, and other files, in a secure and scalable manner. In this article, we will explore how to upload files to Firebase
2 min read
Email Verification using OTP in NodeJS Implementing email verification using OTP in Node.js enhances security by ensuring users provide valid email addresses. It involves generating and sending OTPs to users, verifying them, and confirming their email authenticity. ApproachTo enable Email Verification using OTP in NodeJS we will be using
2 min read
How to authenticate with google using firebase in React ? The following approach covers how to authenticate with Google using firebase in react. We have used firebase module to achieve so.Creating React Application And Installing Module:Step 1: Create a React myapp using the following command:npx create-react-app myappStep 2: After creating your project fo
2 min read
How to list all the files from firebase storage using ReactJS ? To list all the files from Firebase storage using React JS we will access the Firebase storage using the SDK and display the data on the webpage from the storage.Prerequisites:NPM & Node.jsReact JSFirebaseApproach: To list all the files from Firebase storage using ReactJS we will first configure
3 min read
How to get meta data of files in firebase storage using ReactJS ? Within the domain of web development, effective file management is a frequent necessity, and Firebase Storage emerges as a resilient solution. This article explores the nuances of extracting metadata from files housed in Firebase Storage through the lens of ReactJS. PrerequisitesNode JS or NPMReact
2 min read
How to Implement Email Registration and Login using Firebase in React? Implementing Email Registration and Login using Firebase in React allows us to authenticate the users securely. Firebase provides predefined ways to register users and handle authentication. Firebase offers multiple authentication methods like Email-Password, Google, Facebook, etc.ApproachTo impleme
4 min read