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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@charlite/react-temporal

v1.1.1

Published

React hooks for date and time using the JavaScript Temporal API — native in modern browsers and Node.js 26+, polyfill-ready elsewhere.

Readme

react-temporal

npm version License: MIT TypeScript CI

react-temporal is a React hooks library for date and time, built on the JavaScript Temporal API. Temporal reached Stage 4 in 2026 and ships natively in Chrome 144+, Firefox 139+, Edge 144+, and Node.js 26+. This library uses native Temporal when available and falls back to a polyfill for Safari, older browsers, and test environments.

Replace Date, Moment.js, and most date-fns use cases with immutable, time-zone-aware Temporal types — wrapped in idiomatic React hooks.

📖 Full documentation — getting started, API reference, polyfill guide, and TypeScript types.

🤖 Agent guide (OKF v0.2) — machine-readable knowledge in knowledge/.


Why Temporal in 2026?

| | Legacy Date | Temporal | | --- | --- | --- | | Immutability | Mutable | Immutable value objects | | Time zones | Error-prone offsets | First-class ZonedDateTime | | Arithmetic | Millisecond hacks | add, subtract, until, since | | Parsing | Implementation-defined | Strict ISO 8601 | | Browser support | Everywhere | Chrome 144+, Firefox 139+, Edge 144+ | | Node.js | Legacy APIs | 26+ native Temporal (polyfill optional) |


Install

npm install @charlite/react-temporal

Polyfill (Safari, older browsers, Node < 26)

Native Temporal is used automatically when available. For environments without it, install one polyfill:

# Smaller production polyfill (~20 KB gzip) — recommended
npm install temporal-polyfill

# Official reference implementation (~44 KB gzip)
npm install @js-temporal/polyfill

For temporal-polyfill, add this once at your app entry point:

import 'temporal-polyfill/global';

temporal-polyfill is installed automatically as an optional dependency and used as the fallback when native Temporal is unavailable (@js-temporal/polyfill remains supported as an optional peer if you install it yourself).


Usage

All hooks are named exports. Import Temporal from the package or from your polyfill:

import { useTemporalNow, useTemporalZonedNow, Temporal } from '@charlite/react-temporal';

function Clock() {
  const now = useTemporalNow();
  const tokyo = useTemporalZonedNow('Asia/Tokyo');

  return (
    <div>
      <p>UTC: {now.toString()}</p>
      <p>Tokyo: {tokyo.toLocaleString()}</p>
    </div>
  );
}

Configurable clock

import { useTemporalNow, useTemporalClock } from '@charlite/react-temporal';

// Update every 100 ms for a smooth timer UI
const now = useTemporalClock({ intervalMs: 100 });

// Or get zoned time with a custom interval
const local = useTemporalNow({ timeZone: 'Europe/Madrid', intervalMs: 5000 });

Hooks

| Hook | Description | | --- | --- | | useTemporalNow | Current Instant or ZonedDateTime (with timeZone option), auto-updating | | useTemporalClock | Current Instant with configurable tick interval | | useTemporalZonedNow | Current ZonedDateTime for an IANA time zone | | useTemporalInterval | Run a callback on a Duration interval | | useTemporalDuration | Duration between two instants (start.until(end)) | | useTemporalCalendar | Validate and return a calendar ID | | useTemporalTimeZone | Validate and return a time zone ID | | useTemporalFormat | Locale-aware formatting via toLocaleString | | useTemporalRange | Inclusive array of PlainDate between two dates | | useTemporalRelative | Relative time via Intl.RelativeTimeFormat ("in 3 hours") | | useTemporalCountdown | Seconds remaining until a target instant | | useTemporalSchedule | setTimeout aligned to a target instant | | useTemporalParse | Parse an ISO string to Instant | | useTemporalDiff | Duration difference between two instants | | useTemporalWeek | All dates in the ISO week (Mon–Sun) | | useTemporalMonth | All dates in a month | | useTemporalYear | First day of each month in a year | | useTemporalFrom | Parse ISO strings into any Temporal type | | useTemporalSafeParse | Non-throwing parse ({ value, error }) | | useTemporalElapsed | Seconds since an instant (live) | | useTemporalStopwatch | Live { elapsed, seconds } from a start instant | | useTemporalLocalDate | Today's PlainDate in a time zone | | useTemporalCompare | Memoized Temporal.*.compare | | useTemporalWithin | Inclusive range check for instants or dates | | useTemporalAdd | Memoized .add(duration) | | useTemporalCountdownStatus | { seconds, isComplete } countdown |

See examples/ for copy-paste examples, or the docs/ folder for full documentation.


Utilities

| Export | Description | | --- | --- | | Temporal | The Temporal namespace (native or polyfill) | | getTemporal() | Explicit resolver — native first, polyfill fallback | | hasNativeTemporal() | Whether globalThis.Temporal is available |


TypeScript

Full type exports are included. Types are sourced from temporal-polyfill and work with native Temporal at runtime:

import type { TemporalInstant, TemporalPlainDate, UseTemporalNowOptions } from '@charlite/react-temporal';

Testing

npm test

Unit tests use Vitest and live in src/__tests__/.


Development

git clone https://github.com/charlite/react-temporal.git
cd react-temporal
nvm use 26   # requires Node.js 26+
npm install
npm test
npm run build

Contributing

Contributions are welcome! See CONTRIBUTING.md and the OKF knowledge bundle for agent-oriented context.


License

MIT © charlite