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

@i18n-tiny/react

v1.1.1

Published

Tiny, type-safe i18n library for React with automatic type inference and zero dependencies

Readme

@i18n-tiny/react

npm version npm downloads

Tiny, type-safe i18n library for React with automatic type inference and zero dependencies.

Installation

npm install @i18n-tiny/react

Quick Start

1. Define i18n - that's all you need

// src/i18n.ts
import { define } from '@i18n-tiny/react'

const enMessages = {
  common: {
    title: 'Hello',
    welcome: 'Welcome, {name}!'
  }
} as const

const jaMessages = {
  common: {
    title: 'こんにちは',
    welcome: 'ようこそ、{name}さん!'
  }
} as const

// define() gives you everything
export const { Provider, useMessages, useTranslations, useLocale } = define({
  locales: ['en', 'ja'] as const,
  defaultLocale: 'en',
  messages: { en: enMessages, ja: jaMessages }
})

2. Wrap with Provider

// src/App.tsx
import { useState } from 'react'
import { Provider } from './i18n'

function App() {
  const [locale, setLocale] = useState('en')

  return (
    <Provider locale={locale} messages={messages[locale]}>
      <YourApp />
      <button onClick={() => setLocale(locale === 'en' ? 'ja' : 'en')}>
        Toggle Language
      </button>
    </Provider>
  )
}

3. Use in Components

// src/components/Greeting.tsx
import { useMessages, useTranslations, useLocale } from '../i18n'

function Greeting() {
  const messages = useMessages()
  const t = useTranslations()
  const locale = useLocale()

  return (
    <div>
      <h1>{messages.common.title}</h1>
      <p>{t('common.welcome', { name: 'User' })}</p>
      <p>Current locale: {locale}</p>
    </div>
  )
}

API Reference

define(config)

Creates an i18n instance with type-safe hooks.

const { Provider, useMessages, useTranslations, useLocale } = define({
  locales: ['en', 'ja'] as const,
  defaultLocale: 'en',
  messages: { en: {...}, ja: {...} }
})

Returns:

  • Provider - React context provider component
  • useMessages() - Hook to access raw message object
  • useTranslations(namespace?) - Hook to get translation function
  • useLocale() - Hook to get current locale
  • locales - Array of supported locales
  • defaultLocale - Default locale string

Provider

Wraps your app to provide i18n context.

<Provider locale="en" messages={messages.en}>
  {children}
</Provider>

Props:

  • locale: string - Current locale
  • messages: MessageType - Message dictionary for current locale
  • children: ReactNode - Child components

useMessages()

Returns the raw message object with full type inference.

const messages = useMessages()
// messages.common.title is typed as string

useTranslations(namespace?)

Returns a translation function with interpolation support.

const t = useTranslations()
t('common.welcome', { name: 'John' }) // "Welcome, John!"

// With namespace
const t = useTranslations('common')
t('welcome', { name: 'John' }) // "Welcome, John!"

useLocale()

Returns the current locale string.

const locale = useLocale() // "en" | "ja"

TypeScript

Full type inference is automatic:

const t = useTranslations()

// Type error: 'invalid.key' doesn't exist
t('invalid.key')

// Type error: missing required variable
t('common.welcome') // Error: expects { name: string }

License

MIT