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

@devslab/locale-match-react

v0.1.2

Published

React binding for @devslab/locale-match — a useLocale() hook with hydration-safe detection.

Readme

@devslab/locale-match-react

npm

Docs & playground · 한국어

React binding for @devslab/locale-match — locale negotiation that will not hand a Simplified Chinese reader your Traditional text.

npm i @devslab/locale-match @devslab/locale-match-react

Usage

import { LocaleProvider, useLocale } from '@devslab/locale-match-react';

export function App({ serverLocale }) {
  return (
    <LocaleProvider
      supported={['ko', 'en', 'ja', 'zh-HK', 'zh-TW']}
      fallback="ko"
      initial={serverLocale}   // omit in a pure SPA
    >
      <Page />
    </LocaleProvider>
  );
}

function Page() {
  const { locale, setLocale, supported, isFallback } = useLocale();
  return (
    <select value={locale} onChange={(e) => setLocale(e.target.value)}>
      {supported.map((l) => <option key={l}>{l}</option>)}
    </select>
  );
}

Hydration

Detection runs in an effect after mount, never during render.

Server-rendered HTML — including a Next.js static export — carries whatever locale the server knew. If the client picked a different one during its first render, React would find markup that does not match what it was about to draw: a hydration mismatch, which React resolves by throwing the server's HTML away.

The cost of doing it correctly is one frame of the fallback language before the swap. The way to avoid that frame is not a cleverer hook — it is resolving on the server and passing the answer in as initial.

API

| export | what | |---|---| | <LocaleProvider {...config} initial? input?> | takes everything createLocaleResolver takes, plus initial (a locale already resolved on the server) and input (explicit resolve inputs) | | useLocale() | { locale, source, supported, setLocale, isFallback, resolver } |

setLocale ignores unsupported values, including a tag your script guard refuses — so a zh-CN passed by mistake cannot flip a Traditional-only site.

Next.js

Next needs no adapter beyond this one: resolve on the server with the core package and pass the result to <LocaleProvider initial={...}>. The middleware and server-component recipes — and the Vary: Accept-Language warning that goes with them — are in the repo README.

Full documentation: github.com/devslab-kr/locale-match · 한국어

License

Apache-2.0 © devslab