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 Send a User Verification Mail in Web and Firebase ?
In this article, we will see how to send the user verification email to the user, so that only verified users can be signed In to their account using Email Password Authentication. The Drawback of email password authentication is that, when a user signs up using an arbitrary email, firebase allows t
2 min read
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
3 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 configur
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 implem
4 min read
How to get current date and time in firebase using ReactJS ?
This article provides a detailed walkthrough on obtaining the current date and time in a Firebase environment using ReactJS. Readers will gain insights into the implementation process, enabling date and time functionalities into their React projects powered by Firebase. Prerequisites:Node JS or NPMR
2 min read
How To Create A Multi-Page Website Using ReactJS?
Multi-page website using ReactJS is the core for building complex web applications that require multiple views or pages. Previously where each page reloads entirely, ReactJS allows you to navigate between different pages without reloading the whole page thanks to libraries like React Router. In this
4 min read
Fetch and Send with Firestore using ReactJS
To perform fetch and send with Firestore using React require sending and receving data on the firestore database. Firestore is a NoSQL database developed by Google as an alternative to the Firebase database. It has been designed to provide a better developer experience and simplify the development p
4 min read