Gathering detailed insights and metrics for @bradgarropy/use-countdown
Gathering detailed insights and metrics for @bradgarropy/use-countdown
Gathering detailed insights and metrics for @bradgarropy/use-countdown
Gathering detailed insights and metrics for @bradgarropy/use-countdown
npm install @bradgarropy/use-countdown
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (94.95%)
JavaScript (2.84%)
HTML (2.21%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
92 Stars
39 Commits
12 Forks
2 Watchers
1 Branches
5 Contributors
Updated on Jan 30, 2025
Latest Version
2.0.1
Package Id
@bradgarropy/use-countdown@2.0.1
Unpacked Size
25.77 kB
Size
7.22 kB
File Count
15
NPM Version
6.14.18
Node Version
14.21.3
Published on
Oct 12, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
27
React hook countdown timer. As seen on my Twitch streams.
This package is hosted on npm.
1npm install @bradgarropy/use-countdown
In any React component, import useCountdown
, then call it like any other hook. The returned countdown
value will update every second with the remaining time.
1import useCountdown from "@bradgarropy/use-countdown" 2 3const App = () => { 4 const countdown = useCountdown({ 5 minutes: 1, 6 seconds: 30, 7 format: "mm:ss", 8 autoStart: true, 9 onCompleted: () => console.log("onCompleted"), 10 }) 11 12 console.log(countdown) 13 14 // {minutes: 1, seconds: 30, formatted: "01:30", ...} 15 // {minutes: 1, seconds: 29, formatted: "01:29", ...} 16 // {minutes: 1, seconds: 28, formatted: "01:28", ...} 17 // ... 18 // {minutes: 0, seconds: 0, formatted: "00:00", ...} 19 // onCompleted() 20}
useCountdown({minutes, seconds})
Name | Required | Default | Example | Description |
---|---|---|---|---|
minutes | false | 0 | 1 | Countdown minutes. |
seconds | false | 0 | 30 | Countdown seconds. |
format | false | mm:ss | mm:ss:SS | Format string (reference). |
autoStart | false | false | true | Whether or not to automatically start the countdown. |
onCompleted | false | undefined | function | Function to call when countdown completes. |
Starts a countdown timer based on the number of minutes and seconds provided. The returned countdown
object updates once per second and stops when the timer hits zero.
The format
parameter is a date-fns
format string.
If provided, the onCompleted
function will be called when the countdown completes.
Here are some examples of how to call useCountdown
.
1const countdown = useCountdown({ 2 minutes: 1, 3 seconds: 30, 4 format: "mm:ss:SS", 5 autoStart: true, 6 onCompleted: () => console.log("onCompleted"), 7}) 8 9const countdown = useCountdown({ 10 minutes: 5, 11 onCompleted: () => console.log("onCompleted"), 12}) 13 14const countdown = useCountdown({seconds: 10, format: "mm:ss:SS"})
The return object is updated every second until the countdown timer ends.
Name | Type | Example | Description |
---|---|---|---|
minutes | number | 1 | Remaining minutes. |
seconds | number | 30 | Remaining seconds. |
formatted | string | 01:30 | Formatted remaining time. |
isActive | boolean | true | Indicates that the countdown is active, either running or paused. |
isInactive | boolean | false | Indicates that the countdown is inactive, and has finished counting down. |
isRunning | boolean | true | Indicates that the countdown is running. |
isPaused | boolean | false | Indicates that the countdown is paused. |
pause | function | function | Pauses the countdown. |
resume | function | function | Resumes the countdown. |
reset | function | function | Resets the countdown. |
Here is an example of the returned object.
1{ 2 minutes: 1, 3 seconds: 30, 4 formatted: "01:30", 5 isActive: true, 6 isInactive: false, 7 isRunning: true, 8 isPaused: false, 9 pause: () => void, 10 resume: () => void, 11 reset: (time?: Time) => void, 12}
🐛 report bugs by filing issues
📢 provide feedback with issues or on twitter
🙋🏼♂️ use my ama or twitter to ask any other questions
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
Found 3/16 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More