How to use React Icons in Next.js ?
Last Updated :
13 May, 2024
Icons make the website beautiful and interactive. Icons are an important part of a website's user interfaces, which are used in expressing objects, actions, and ideas. They are used to communicate the core idea and intent of a product or action and express the object visually. Here, we will learn to use React icons in Next JS applications.
Prerequisites:
Approach to use React Icons in Next.js
- Firstly, Install the react-icon package using the npm command.
- This Next.js app imports the "FaBeer" icon from the "react-icons/fa" library.
- Within the "Home" component, it displays a title "Using React Icons in NextJS" alongside the "FaBeer" icon.
- Use Custom CSS for extra styling to the webpage.
Steps to Create the Next.js Application
Step 1: Create a Next application using the following command.
npx create-next-app@latest react-icon-nextapp
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd react-icon-nextapp
Step 3: Install react icons in the folder
npm install react-icons --save
Project Structure:

The updated dependencies in package.json file will look like:
"dependencies": {
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"react-icons": "^5.2.0"
},
Example 1: The below example shows how to use react icons in a simple page.
CSS
.style_main{
background-color: black;
color: white;
text-align: center;
height: 100vh;
}
JavaScript
// Filename - page.js
import { FaBeer } from 'react-icons/fa';
import "./style.css";
export default function Home() {
return (
<main className="style_main">
<h1>GeeksForGeeks NextJS Concepts</h1>
<h3><b>Using React Icons in NextJS</b></h3>
<FaBeer /><br />
</main>
);
}
Step to Run Application: Run the application using the following command from the root directory of the project
npm run dev
Output:
OutputExample 2: The below example shows how to use react icons in a simple page with different font sizes to various react-icons.
CSS
.style_main{
background-color: black;
color: white;
text-align: center;
height: 100vh;
}
JavaScript
// Filename - page.js
import { FcCallTransfer, FcBarChart } from 'react-icons/fc';
import { Bs8CircleFill, BsAlarmFill } from "react-icons/bs";
export default function Home() {
return (
<main className=" style_main">
<h1>GeeksForGeeks NextJS Concepts</h1>
<h3><b>Using React Icons in NextJS</b></h3>
<FcCallTransfer fontSize={20} /><br />
<FcBarChart fontSize={30} /><br />
<BsAlarmFill fontSize={40} /> <br />
<Bs8CircleFill fontSize={45} />
</main>
);
}
Output:

Example: The below example showsuse React icons in Next.js with additional style using CSS in your "style.css".
CSS
.myIconClass{
color: green;
background-color: yellow;
}
.style_main{
background-color: black;
color: white;
text-align: center;
height: 100vh;
}
JavaScript
import "./style.css";
import { FcCallTransfer, FcBarChart } from 'react-icons/fc';
import { Bs8CircleFill, BsAlarmFill } from "react-icons/bs";
export default function Home() {
return (
<main className="style_main">
<h1>GeeksForGeeks NextJS Concepts</h1>
<h3><b>Using React Icons in NextJS</b></h3>
<FcCallTransfer fontSize={20} /><br />
<FcBarChart fontSize={30} /><br />
<BsAlarmFill fontSize={40} /> <br />
<Bs8CircleFill fontSize={45} className="myIconClass" />
</main>
);
}
Output:
Similar Reads
How to use Icon Component in React JS? Every application requires icons for UI purposes, and integrating them with Material UI for React is seamless. Utilize the Icon Component in ReactJS effortlessly by following this straightforward approach. Prerequisites:NodeJS or NPMReact JSMaterial UISteps to create React Application And Installing
2 min read
How to use React Icons npm Package in React? The React Icons NPM package allows us to easily include popular icons in our React project. It provides a vast collection of icons from various icon libraries like Font Awesome, Material Design, and others wrapped in React Components. This enables us to seamlessly integrate these icons into our reac
3 min read
How to use Bootstrap Icons in React ? React is a free library for making websites look and feel cool. With React, your websites can be super interactive and lively. Itâs great for making modern websites where everything happens on one page. The best part is that you can build and reuse different parts of your webpage, making it easy to
2 min read
How to add Web Share in Next.js ? The Web Share API enables web applications to share content (like URLs, text, or files) to other apps installed on a user's device, such as social media platforms, messaging apps, or email clients. Integrating the Web Share API into a Next.js project enhances user experience by providing a seamless
2 min read
How to use List Component in ReactJS? Lists are continuous, vertical indexes of text or images. Material UI for React has this component available for us, and it is very easy to integrate. We can use the List Component in ReactJS using the following approach. Prerequisites:NodeJS or NPMReactJSSteps to Create the React Application And In
2 min read
How to Use the App Directory in Next.js? The App Directory in Next.js provides a powerful way to structure and manage your application's pages and components. It simplifies the routing and organization of your project, enabling you to build complex web applications with ease.Understanding the App DirectoryThe App Directory is a new structu
3 min read
How to use Material UI Icons ? Material UI Icons is a library that provides a collection of pre-designed icons following Google's Material Design guidelines. These icons can be easily integrated into React applications to enhance visual elements and improve user experience. Installation// Package containing Material UI icon compo
1 min read
How to import image in Next.js ? Next.js is a full-stack React-based framework. Unlike a traditional react app, which loads and renders the entire application on the client, Next.js allows the first-page load to be rendered by the server, which is great for SEO and performance. Some of the key features of Next.js are:Â Server-side
4 min read
React Suite Nav Used with Link in next/link React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. Nav Provides a list of various forms of navigation menus, which can be landscape and portrait layouts.  Nav Items can be used with Links also. These can be used
3 min read
How to Import SVGs Into Your Next.js Apps? Next.js is a powerful React framework that simplifies building and deploying web applications. Incorporating SVGs (Scalable Vector Graphics) into your Next.js projects can enhance your user interface with high-quality, scalable images. In this article, we will see how to Import SVGs Into Your Next.j
5 min read