npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

my-awesome-react-timer

v1.1.3

Published

A React hook and Timer component

Readme

my-awesome-react-timer

A React hook (useTimer) and a Timer component that make it easy to create both countdown or count-up timers in your React applications. This library provides simple, configurable timers with optional SVG-based progress indicators (circle), warning colors for critical times, and more.

Storybook Live Demo

Live Storybook Demo

Table of Contents

Features

  • Countdown or Countup with useTimer.
  • SVG-based progress (circular or linear) for visually indicating the timer’s state.
  • Customizable colors, stroke widths, font sizes, etc.
  • Lightweight and easy to integrate into any React project.

Installation

npm install my-awesome-react-timer

Make sure you have React (v19+) installed, as defined in the peer dependencies.

Usage

Using the Hook

import React from 'react';
import { useTimer } from 'my-awesome-react-timer';

function MyTimerHookDemo() {
const { time, startTimer, stopTimer, resetTimer } = useTimer({
initialTime: 60,  // start at 60 seconds
endTime: 0,       // stop at 0
autoStart: false, // don't start immediately
onFinished: () => console.log('Timer finished!'),
});

return (
<div>
<h3>Time Left: {time}</h3>
<button onClick={startTimer}>Start</button>
<button onClick={stopTimer}>Stop</button>
<button onClick={() => resetTimer()}>Reset</button>
</div>
);
}

export default MyTimerHookDemo;

Using the Timer Component

import React from 'react';
import { Timer } from 'my-awesome-react-timer';

function MyTimerComponentDemo() {
// Typically, you'd have 'time' coming from the useTimer hook
// or some state logic, but for demo let's just set it statically.
return (
<div style={{ width: 150, height: 150 }}>
<Timer
time={50}         // current time value
strokeWidth={6}
useWarningColors={true}
frontStrokeColor="green"
backStrokeColor="lightgray"
/>
</div>
);
}

export default MyTimerComponentDemo;

Props

Timer

| Prop | Type | Default | Description | |----------------------|---------------|-------------|-----------------------------------------------------| | time | number | required | Current time (in seconds). | | strokeWidth | number | 4 | Stroke width for the SVG circle. | | frontStrokeColor | string | green | Color for the primary/timer stroke. | | backStrokeColor | string | gray | Background stroke color. | | timeDisplayColor | 'string' | 'black' | Text color for the displayed time. | | useWarningColors | boolean | true | If true, changes color to orange/red near the end.. |

useTimer

| Prop | Type | Default | Description | |----------------------|---------------|----------|-----------------------------------------------------| | initialTime | number | 60 | Starting time in seconds. | | endTime | number | 0 | When the timer stops. | | autoStart | boolean | false | If true, starts the timer immediately. | | onFinished | function | () => {}| Function to run when the timer finishes. |

useTimer returns an object:

{
time: number,               // current time
startTimer: () => void,     // function to start the timer
stopTimer: () => void,      // function to pause the timer
resetTimer: (val?: number) => void, // resets time to initial or to a custom value
}

Demo

Final Outcome Final Outcome Final Outcome Final Outcome

Contributing

  1. Fork this repository
  2. Create a new branch for your feature or bugfix: git checkout -b feature/some-improvement
  3. Make your changes, write tests, commit, and push
  4. Create a Pull Request with a clear explanation of what you’ve done
  5. All contributions and suggestions are welcome!

License

This project is licensed under the MIT License.