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

@wads.dev/i18n-react

v0.0.1-alpha.0

Published

Typed React runtime for @wads.dev/i18n-ts translation catalogs.

Readme

@wads.dev/i18n-react

Typed React bindings for translation catalogs built with @wads.dev/i18n-ts.

The package creates an isolated translation runtime containing a Provider and a selector-based hook. It also renders typed translation tokens as React nodes. It does not own project translations, storage or platform-specific locale detection.

Status: 0.0.1-alpha.0. Public APIs may change before 1.0.0.

Installation

npm install @wads.dev/i18n-ts@alpha @wads.dev/i18n-react@alpha

React is a peer dependency. The minimum supported version is 16.8.0, where Hooks were introduced. The distributed JavaScript uses createElement rather than the newer automatic JSX runtime, so the package does not force a newer React version on consuming projects.

Create the project runtime

Keep the reusable package separate from the application's catalog and bootstrap behavior:

import { createTranslationRuntime } from '@wads.dev/i18n-react'
import type { AvailableLangs, Translation } from '@wads.dev/i18n-ts'

interface AppTranslation extends Translation {
  commons: {
    continue: string
  }
  cart: {
    itemCount: (count: number) => string
  }
}

type AppLanguage = 'en' | 'pt'

const languages = {
  en: {
    name: 'English',
    short: 'EN',
    locale: 'en-US',
    lang: () => import('./translations/en.js'),
  },
  pt: {
    name: 'Português',
    short: 'PT',
    locale: 'pt-BR',
    lang: () => import('./translations/pt.js'),
  },
} satisfies AvailableLangs<AppLanguage, AppTranslation>

export const { TranslationProvider, useTranslation } =
  createTranslationRuntime<AppLanguage, AppTranslation>({
    availableLangs: languages,
    defaultLang: 'en',
    onLanguageLoaded: (language) => {
      console.info(`Loaded ${language.locale}`)
    },
  })

Render the Provider at the application boundary:

<TranslationProvider>
  <App />
</TranslationProvider>

Read translations

Select the smallest useful scope:

const { scoped: cart } = useTranslation((translation) => translation.cart)

cart.itemCount(3)

Calling the hook without a selector returns the complete deeply readonly translation tree:

const { scoped: translation, current, available, saved, setLanguage } = useTranslation()

useTranslation throws a descriptive error when called outside its matching Provider.

Change language

const { setLanguage } = useTranslation()

setLanguage('pt', true)

Passing undefined asks @wads.dev/i18n-ts to select from the environment locale and configured default. The current alpha keeps the selected value in Provider state; persistence is intentionally the consuming application's responsibility.

Render typed tokens

withRender turns a %token% template into a typed renderable translation:

import { withRender } from '@wads.dev/i18n-react'

const terms = withRender(
  'I accept the %terms% and %privacy%.',
  {
    terms: 'Terms of Use',
    privacy: 'Privacy Policy',
  },
  {
    terms: (text) => <a href="/terms">{text}</a>,
    privacy: (text) => <a href="/privacy">{text}</a>,
  },
)

Token names are inferred from the provided record and remain compatible with the TranslationRender contract from @wads.dev/i18n-ts.

Multiple runtimes

Every call to createTranslationRuntime creates a distinct React Context. Independent applications, previews or embedded trees can therefore use different catalogs without a global singleton.

Public API

  • createTranslationRuntime(options) — creates a typed Provider and hook.
  • withRender(template, tokens, renders?) — creates typed rich/tokenized text.
  • CreateTranslationRuntimeOptions — runtime factory options.
  • TranslationRuntime — factory result.
  • TranslationContext, TranslationSelector and UseTranslationResult — integration types.

Package boundaries

  • Translation contracts and language loading belong to @wads.dev/i18n-ts.
  • React Context, hooks and React-node rendering belong here.
  • Catalog composition, selected-language persistence and application bootstrap remain in the consuming project.
  • Bundle editing and source-file generation belong to @wads.dev/i18n-editor.

Development

npm install
npm run check
npm run build
npm pack --dry-run

The package publishes ESM JavaScript and TypeScript declarations from dist/.

License

MIT