react-timeago

A tiny React component that renders live, self-updating relative timestamps like "5 minutes ago".

Library
npm
v8.3.0
1,096stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity16
Maintenance20
Community72
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture62
Code Quality65
Innovation76
Learning Curve72

react-timeago is a focused React component for displaying relative time (“5 minutes ago”, “in 2 days”) that keeps itself in sync without a page refresh. It wraps a date in a <time> element and schedules its own re-renders on a variable interval — updating every second for recent timestamps and backing off to hourly or weekly ticks as the timestamp ages, so it never over-renders.

Beyond the default English formatter, the library ships with translated strings for more than 70 languages, an opt-in formatter built on the native Intl.RelativeTimeFormat API, and a fully pluggable formatter function for teams that want complete control over the output. At roughly a hundred lines of core logic, it stays intentionally small while covering the corner cases (custom now() for SSR, configurable min/max update periods, arbitrary wrapper components) that hand-rolled “time ago” implementations usually get wrong.

What You Get

  • A drop-in <TimeAgo date={...} /> component that renders a live-updating <time> element (or any custom component via the component prop)
  • A self-scheduling update loop that ticks every second for fresh timestamps and progressively backs off to minute/hour/week intervals as the timestamp ages, capped by configurable minPeriod/maxPeriod
  • Translated formatter strings for 70+ languages via buildFormatter, plus a short-form variant for many locales
  • An Intl.RelativeTimeFormat-backed formatter (makeIntlFormatter) for locale-correct output using the browser’s built-in internationalization engine
  • A fully pluggable formatter prop so teams can return custom strings or React nodes instead of the default output
  • Server-render-safe now() override so the initial render matches between server and client

Common Use Cases

  • Showing “posted 3 hours ago” style timestamps under comments, feed items, or notifications that update live as the page stays open
  • Displaying last-updated/last-seen indicators (e.g. “last active 5 minutes ago”) in dashboards and admin panels
  • Localizing relative timestamps for an international audience using the built-in language strings or the Intl formatter
  • Building custom time displays (e.g. “just now”, “yesterday”) by supplying a custom formatter function

Under The Hood

Architecture: The entire library centers on one component, TimeAgo (src/index.js), built with useState/useEffect hooks rather than a class-based timer pattern. On each render it computes the elapsed time between date and the current timeNow state, derives the next update delay from that elapsed time (1s under a minute, 1 minute under an hour, 1 hour under a day, otherwise capped by maxPeriod), and schedules exactly one setTimeout for that delay — clearing it on unmount or when date/live/minPeriod/maxPeriod change. Formatting is delegated to a pluggable formatter function that receives (value, unit, suffix, epochMilliseconds, nextFormatter, now), with defaultFormatter (src/defaultFormatter.js) as the fallback and nextFormatter letting a custom formatter selectively defer back to the default for cases it doesn’t handle. dateParser.js normalizes the three accepted date input shapes (Date object, string, epoch number) into a single Date.

Tech Stack: Written in Flow-typed JavaScript (not TypeScript) with Babel for compilation to two output targets — CommonJS (lib/) and ES modules (es6/) — declared via package.json exports conditions. Type declarations are generated post-build from the Flow annotations via a custom scripts/gen-types.js script (using flow-api-translator) rather than hand-written .d.ts files. The only runtime dependency is react itself as a peer dependency (16–19 supported); everything else (Babel, ESLint with hermes-eslint/Prettier via prettier-plugin-hermes-parser, Rollup for the examples bundle, Jest) is a dev-only tool.

Code Quality: Two Jest test files (__tests__/index.js, __tests__/formatter-value-tests.js, ~160 lines combined) cover the component’s rendering and the value/unit boundary logic (second→minute→hour→day→week→month→year thresholds) using @testing-library/react and a jsdom environment; npm test runs with coverage enabled. The formatter call is wrapped in a try/catch that logs and falls back to defaultFormatter if a custom formatter throws, and an invalid date triggers a console.warn and a null render rather than a crash. Linting is enforced via a fairly strict ESLint config (eslint-plugin-flowtype/ft-flow, import, react-hooks, prettier).

Used by 7 apps in this directory

TypeScript
53%
Other

Chaskiq

CRM · Customer Support

3,560

Self-hosted live chat, video calls, help center, and marketing automation — a full-stack Intercom alternative you run on your own infrastructure.

View details
60
Repo Health
66
Technical
68
Dependency
Built with
TypeScript53%
Ruby36%
Updated 1 months ago
Java
48%
Apache 2.0

ClearFlask

Product Management · Community

448

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
83
Repo Health
73
Technical
63
Dependency
Built with
Java48%
TypeScript47%
Updated 2 weeks ago
Go
68%
MIT

Gotify

Monitoring · Developer Tools

15,752

A lightweight, self-hosted push notification server that sends and receives messages in real time over WebSocket, with a sleek web UI and a native Go plugin system.

View details
89
Repo Health
74
Technical
71
Dependency
Built with
Go68%
TypeScript30%
Updated 3 days ago
Go
61%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,017

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
65
Dependency
Built with
Go61%
TypeScript34%
Updated 2 days ago
Python
63%
Other

Keep

Devops · Automation · Monitoring

12,224

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
91
Repo Health
79
Technical
67
Dependency
Built with
Python63%
TypeScript36%
Updated today
Python
67%
Apache 2.0

Polar

Ecommerce · Developer Tools · Invoicing Finance

10,199

Open source payments infrastructure that turns software into a business — subscriptions, usage-based billing, digital products, and merchant-of-record compliance in one platform.

View details
90
Repo Health
82
Technical
71
Dependency
Built with
Python67%
TypeScript26%
Updated today
TypeScript
91%
MIT

SerpBear

Marketing · Analytics

2,048

Self-hosted keyword rank tracker with Google Search Console integration, multi-provider SERP scraping, and a built-in REST API.

View details
50
Repo Health
67
Technical
68
Dependency
Built with
TypeScript91%
Updated 3 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search