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

anyfamily-react

v2.2.0

Published

React hooks for the any* family — useAnywhen, useAnyamount, useAnyamountSymbol, useAnymany, useAnyaround, useAnylong, useAnyplural, useAnyword, useAnylocale, with live-updating relative time and a shared locale provider.

Readme

anyfamily-react

anyfamily — anywhen · anyamount · anymany · anyaround · anylong · anyplural · anyword · anylocale

React hooks for the any* family: anywhen, anyamount, anymany, anyaround, anylong, anyplural, anyword and anylocale as hooks, sharing one locale and keeping relative time fresh without hand-rolled setInterval plumbing.

anyfamily.site

npm install anyfamily-react

Also published to GitHub Packages, where names must carry the owner's scope: @kirilinsky/anyfamily-react. GitHub requires auth even for public packages, so add a token with read:packages to your .npmrc:

@kirilinsky:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
npm install @kirilinsky/anyfamily-react

Same code, same version, different name — npmjs is the primary registry.

import { AnyfamilyProvider, useAnywhen, useAnyamount } from "anyfamily-react";

function App() {
  return (
    <AnyfamilyProvider locale="en">
      <Post publishedAt={post.createdAt} price={1999} />
    </AnyfamilyProvider>
  );
}

function Post({ publishedAt, price }: { publishedAt: Date; price: number }) {
  const when = useAnywhen(publishedAt, { mode: "relative" }); // "3 hours ago", ticks itself
  const cost = useAnyamount(price, { mode: "currency", currency: "EUR" });
  return <p>{cost} — {when}</p>;
}

why hooks and not just the functions

  • AnyfamilyProvider — set locale once, every hook below picks it up. A hook's own options.locale always wins over the provider. Changing the provider's locale re-renders every hook under it, same as any React context.

  • defaults for the settings that never vary — a currency, a time zone, a style, repeated at forty call sites, set once instead. One slot per hook family; a call site's own options win key by key.

    <AnyfamilyProvider
      locale="de-DE"
      defaults={{
        anyamount: { mode: "currency", currency: "EUR" },
        anywhen: { refresh: 30_000 },
      }}
    >
    useAnyamount(1999);                                    // "1.999,00 €"
    useAnyamount(1999, { mode: "currency", currency: "USD" }); // the call wins
    useAnyamount(3.2, { mode: "unit", unit: "gigabyte" });  // another mode: the
    // default's currency is dropped rather than carried in. Only `locale` crosses
    // modes.

    useAnyfamilyDefaults() reads them back, for wrapping a hook of your own.

  • useAnywhen ticks itself — relative output ("3 minutes ago") goes stale the instant the component stops re-rendering. The hook re-renders on an interval (default 60s, refresh to override, refresh: false to disable) so it doesn't. No tick in "absolute" mode or once a date is over a day old — nothing left that a minute-granularity poll would change. The default tick is a fixed poll, not synced to unit boundaries: a transition like "59 seconds ago" → "1 minute ago" can lag up to one tick behind. Pass an explicit refresh if you need tighter alignment.

hooks

  • useAnywhen(date, options?) — see anywhen. options.refresh controls the tick interval.
  • useAnyamount(value, options?) — see anyamount.
  • useAnyamountSymbol(currency, options?) — see anyamount.symbol. The bare currency symbol, for labels and input affixes where the amount is rendered separately.
  • useAnymany(items, options?) — see anymany.
  • useAnyaround(code, options?) — see anyaround.
  • useAnylong(input, options?) — see anylong. anylongSupported is re-exported for the same feature-detection anylong itself provides.
  • useAnyplural(count, forms, options?) — see anyplural.
  • useAnyword(text, options?) — see anyword. Returns string[], memoized on the text and the options' contents, so the array keeps its reference between renders and is safe as an effect dependency.
  • useAnywordCount(text, options?) — see anyword.count.
  • useAnywordTruncate(text, limit, options?) — see anyword.truncate. anywordSupported is re-exported for feature-detecting Intl.Segmenter, which all three anyword hooks require.
  • useAnylocale(tag?) — see anylocale. Unlike the others it takes the tag as its argument, so with no argument it falls back to the provider's locale and then to the runtime's. Returns an object, memoized on the tag, so it is safe as an effect dependency. anylocaleSupported is re-exported for feature-detecting Intl.Locale info.

useAnyfamilyLocale() reads the locale from the nearest provider directly, for anything not covered by the hooks above.

the plain functions, too

All eight are re-exported, so formatting outside a hook — in an event handler, inside a useMemo, in a callback handed downward — doesn't need the underlying package as a second dependency:

import { anywhen, anyword } from "anyfamily-react";

<button onClick={() => copy(anywhen(post.createdAt, { mode: "absolute" }))}>

They are the same bindings the hooks call, extras included — anyword.count, anyamount.symbol, anylong.supported. They carry this package's "use client" boundary with them: to format in a server component, import from anyfamily instead.

anywhen · anyamount · anymany · anyaround · anylong · anyplural · anyword · anylocale

license

MIT © kirilinsky