Skip to content
Related Articles

Related Articles

How to add Timer in Next.js ?

Improve Article
Save Article
Like Article
  • Last Updated : 15 Nov, 2021

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:


import { CountdownCircleTimer } from 
export default function Timer(){
  return (
      <h3>GeeksforGeeks - Timer</h3>
          ['#004777', 0.33],
          ['#F7B801', 0.33],
          ['#A30000', 0.33],
        {({ remainingTime }) => remainingTime}

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


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!