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

@bf-i18n/react

v0.5.7

Published

React integration for backend-friendly i18n

Readme

@bf-i18n/react

CI npm version License: MIT

React integration for bf-i18n. Provides hooks, components, and HOC to use Rails/Laravel translation formats in your React applications.

Part of the bf-i18n project.

Installation

npm install @bf-i18n/react

Features

  • React context provider
  • Hooks for translations and locale management
  • Trans component for JSX-based translations
  • HOC for class components
  • Reactive locale updates

Usage

Setup

import { createI18n } from '@bf-i18n/core';
import { I18nProvider } from '@bf-i18n/react';

const i18n = createI18n({
  defaultLocale: 'en',
  mode: 'rails',
  translations: {
    en: {
      greeting: 'Hello, %{name}!',
      items: {
        one: '1 item',
        other: '%{count} items',
      },
    },
  },
});

function App() {
  return (
    <I18nProvider i18n={i18n}>
      <MyComponent />
    </I18nProvider>
  );
}

useTranslation Hook

import { useTranslation } from '@bf-i18n/react';

function MyComponent() {
  const { t, locale, setLocale } = useTranslation();

  return (
    <div>
      <p>{t('greeting', { name: 'React' })}</p>
      <p>{t('items', { count: 5 })}</p>
      <p>Current locale: {locale}</p>
      <button onClick={() => setLocale('ja')}>
        Switch to Japanese
      </button>
    </div>
  );
}

useLocale Hook

import { useLocale } from '@bf-i18n/react';

function LocaleSwitcher() {
  const { locale, setLocale, availableLocales } = useLocale();

  return (
    <select value={locale} onChange={(e) => setLocale(e.target.value)}>
      {availableLocales.map((loc) => (
        <option key={loc} value={loc}>{loc}</option>
      ))}
    </select>
  );
}

useI18n Hook

import { useI18n } from '@bf-i18n/react';

function DebugComponent() {
  const i18n = useI18n();

  return (
    <pre>{JSON.stringify(i18n.getMissingKeys(), null, 2)}</pre>
  );
}

Trans Component

import { Trans } from '@bf-i18n/react';

function Welcome() {
  return (
    <Trans
      i18nKey="greeting"
      values={{ name: 'React' }}
    />
  );
}

withTranslation HOC

import { withTranslation, WithTranslationProps } from '@bf-i18n/react';

interface Props extends WithTranslationProps {
  name: string;
}

class Greeting extends React.Component<Props> {
  render() {
    const { t, name } = this.props;
    return <p>{t('greeting', { name })}</p>;
  }
}

export default withTranslation(Greeting);

API

Components

  • I18nProvider - Context provider
  • Trans - Translation component

Hooks

  • useTranslation() - Returns { t, locale, setLocale }
  • useLocale() - Returns { locale, setLocale, availableLocales }
  • useI18n() - Returns the I18n instance

HOC

  • withTranslation(Component) - Injects t, locale, setLocale props

License

MIT