New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

usehmtimer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usehmtimer

All about time - React hook

latest
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

Of course! 🚀
Let’s make you a professional and clean README.md for your package usehmtimer.

Here’s a full version you can directly use:

usehmtimer

⏳ A lightweight React hook for handling timers, countdowns, and time-ago formatting easily!

✨ Features

  • 🕐 Timer — Start, stop, reset a simple timer.
  • 📅 Countdown — Calculate remaining time to a future target date.
  • 🌎 Localized "Time Ago" — Format time ago in English or Arabic.
  • ⚡ Built with TypeScript — Full types support.
  • 📦 Small and tree-shakable.

📦 Installation

npm install usehmtimer

or with yarn:

yarn add usehmtimer

🚀 Usage

import useMyTimer from "usehmtimer";

function MyComponent() {
  const { timeAgo, seconds, remaining, StartTimer, StopTimer, ResetTimer } =
    useMyTimer({ targetDate: "2025-12-31T23:59:59" });

  return (
    <div>
      <p>Timer seconds: {seconds}</p>
      <p>Remaining Days: {remaining.days}</p>
      <button onClick={StartTimer}>Start</button>
      <button onClick={StopTimer}>Stop</button>
      <button onClick={ResetTimer}>Reset</button>
    </div>
  );
}

🛠️ API

useMyTimer(props?: UseMyTimerProps)

PropTypeDescription
targetDatestring(Optional) ISO string of the future target date, e.g., "2025-12-31T23:59:59".

Returned Values:

NameTypeDescription
timeAgo(date1, date2, lang?)(string, string, "ar" | "en") => stringCalculate time difference human-readable (e.g., "2 hours ago").
secondsnumberTimer seconds since started.
remainingDateSectionsObject containing { years, months, days, hours, minutes, seconds } till targetDate.
StartTimer() => voidStart the seconds timer.
StopTimer() => voidStop the timer.
ResetTimer() => voidReset seconds to 0.

📚 Types

type DateSections = {
  years: number;
  months: number;
  days: number;
  hours: number;
  minutes: number;
  seconds: number;
};

interface UseMyTimerProps {
  targetDate?: string;
}

⚖ License

MIT © Habib Mohammed

🙌 Contributing

Feel free to open issues or pull requests to improve this hook!
PRs and ideas are very welcome ✨

📢 Notes

  • If you use remaining, it's better to pass a targetDate to useMyTimer.
  • Fully compatible with React 18+ and React 19.

Would you like me also to make you a small badge section (like "npm version", "bundle size", etc.)? 🚀✨ It will make your README look even cooler! 🎖️
Want me to add it? 🎨👑

FAQs

Package last updated on 26 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts