Saturday, January 17, 2026
HomeLanguagesHow to add Timer in Next.js ?

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.

Approach: To add our Timer we are going to use the react-countdown-circle-timer package. The react-countdown-circle-timer package helps us to integrate different types of timers. So first, we will install the react-countdown-circle-timer package, and then we will add timer on our homepage.

Create NextJS Application: You can create a new NextJs project using the below command:

npx create-next-app gfg

Install the required package: Now we will install the react-countdown-circle-timer package using the below command:

npm i react-countdown-circle-timer

Project Structure: It will look like this.

Adding the Timer: After installing the react-countdown-circle-timer package we can easily add Timer in our app . For this example, we are going to add timer to our homepage.

Add the below content in the index.js file:

Javascript




import { CountdownCircleTimer } from 
    'react-countdown-circle-timer'
  
export default function Timer(){
  return (
    <div>
      <h3>neveropen - Timer</h3>
      <CountdownCircleTimer
        isPlaying
        duration={10}
        colors={[
          ['#004777', 0.33],
          ['#F7B801', 0.33],
          ['#A30000', 0.33],
        ]}
      >
        {({ remainingTime }) => remainingTime}
      </CountdownCircleTimer>
    </div>
    
  )
}


Explanation: In the above example first, we are importing our CountdownCircleTimer component from the installed package. After that, we are using the component and set the initial properties like isPlaying, duration, and color. Then we are displaying the remainingTime.

Steps to run the application: Run the below command in the terminal to run the app.

npm run dev

Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
118 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12062 POSTS0 COMMENTS
Shaida Kate Naidoo
6985 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS