Skip to main content
Version: 5.7.2



Count down to a target timestamp and call callbacks every second (or provided peried)


npm install --save rooks

Importing the hook​

import { useCountdown } from "rooks";


const endTime = new Date( + 10000);

function Demo() {
const count = useCountdown(endTime, {
interval: 1000,
onDown: (time) => console.log("onDown", time),
onEnd: (time) => console.log("onEnd", time),
return count;

render(<Demo />);


ArgumentTypeDescriptionDefault value
endTimeDatethe time when the countdown should endundefined
options.intervalnumbermilliseconds that it takes count down once1000
options.onDownfunction(time) => {}, callback that would be called every intervalundefined
options.onEndfunction(time) => {}, callback that would be called when the countdown endsundefined

Return Value​

numberrest amount of intervals it takes to count down to the endTime

Codesandbox Examples​

Basic Usage​

Join Bhargav's discord server​

You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.