How to add Calendar in Next.js ?
Last Updated :
29 Jul, 2024
Adding a calendar to a Next.js application enhances scheduling and event management. We can just install and use the available npm package. In this article, we are going to learn how we can add a calendar loader in NextJS.
Approach
To add our calendar we are going to use the react-calendar package. The react-calendar package helps us to integrate calendars in our app. So first, we will install the react-calendar package and then we will add a calendar on our homepage.
Steps to Create Next App and Installing Module
Step 1: Create a React application using the following command.
npx create-next-app gfg
Step 2: After creating your project folder i.e. gfg, move to it using the following command.
cd gfg
Step 3: Now we will install the react-calendar package using the below command
npm i react-calendar
Project Structure:

The updated dependencies in the package.json file are:
"dependencies": {
"next": "14.2.4",
"react": "^18",
"react-calendar": "^5.0.0",
"react-dom": "^18"
}
Adding the Calendar
After installing the package we can easily add a calendar on any page in our app.
Example: This example demonstrate addin calender by importing calendar component from the react-calendar package.
JavaScript
// Filename - index.js
import React, { useState } from 'react';
import Calendar from 'react-calendar';
import 'react-calendar/dist/Calendar.css';
export default function CalendarGfg() {
const [value, onChange] = useState(new Date());
return (
<div>
<h1>NextJs Calendar - GeeksforGeeks</h1>
<Calendar
onChange={onChange}
value={value}
/>
</div>
);
}
In the above example first, we are importing the Calendar component and after that, we are using the useState hook to store the current date. Then we are adding our calendar using the imported component.Â
Steps to run the application: Run the below command in the terminal to run the app.
npm run dev
Output:
Similar Reads
How to add a Digital Clock in Next.js ? Adding a digital clock to your Next.js application can enhance the user experience by providing real-time updates in an aesthetically pleasing manner. We can simply add it with packages available on NPM. In this article, we are going to learn how we can add Clock in Next.jsApproachTo add our Clock w
2 min read
How to add Timer in Next.js ? In this article, we are going to learn how we can add Timer in NextJS. NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. The linking of dynamic paths helps in rendering your NextJS components conditionally.
2 min read
How to Add Simple DatePicker in Next.js ? In this article, we are going to learn how we can add a Simple Datepicker in NextJs. NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. The linking of dynamic paths helps in rendering your NextJS components
2 min read
How to Add ChartJS in NextJS 13? Chart.js in Next.js is the package used to create interactive and visually appealing charts, such as line charts, bar charts, and more, seamlessly integrated into Next.js applications. In this article, we will explore the demonstration of various charts in the NextJS application. Table of Content Im
3 min read
How to add DatePicker in NuxtJS ? In this article, we are going to learn how we can add a Datepicker in NuxtJs. Nuxt.js is a free and open-source web application framework based on Vue.js, Node.js, Webpack, and Babel.js. Nuxt is inspired by Next.js, which is a framework of similar purpose, based on React.js.Approach: To add our Date
2 min read