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

react-localite

v1.1.0

Published

A lightweight, fully type-safe React i18n library with lazy-loaded translations, interpolation, and rich text support.

Readme

React Localite

CI Size Quality npm

A lightweight, fully type-safe React internationalization library with lazy-loaded dictionaries and zero runtime key typing.

Features

  • Full TypeScript autocomplete for translation keys
  • Nested translation dictionaries
  • Lazy-loaded dictionaries with caching
  • Placeholder and tags interpolation
  • React Context based
  • Fallback locale support
  • Persistent locale storage
  • Strongly typed translation parameters
  • Global dictionary scopes

Installation

# npm
npm install react-localite

# yarn
yarn add react-localite

# pnpm
pnpm add react-localite

Create translations

import { initTranslations } from "react-localite"

const { TranslationProvider, useTranslation } = initTranslations(
    {
        en: {
            home: {
                title: "Home",
                description: "Welcome",
            },
        },
        ru: () => import("./locales/ru"),
        fr: () => fetch("https://api.somesite.com/locales/fr"),
    },
    {
        fallbackLocale: "en",
    },
)

Provider

Wrap your application.

<TranslationProvider>
    <App />
</TranslationProvider>

Usage

Translation keys are fully inferred from your dictionary. To avoid repeating long prefixes, use a global key.

function Home() {
    const { t } = useTranslation("home")

    return (
        <>
            <h1>{t("title")}</h1>
            <p>{t("description")}</p>
        </>
    )
}

Interpolation

Dictionary:

export default {
    welcome: "Hello, {{ firstName }} {{ lastName }}!",
    profile: "Please visit your <link>profile page</link>",
}

Usage:

t("welcome", {
    firstName: "John",
    lastName: "Doe",
})

t("profile", {
    link: content => <a href="/profile">{content}</a>,
})

Parameters are inferred automatically from the translation string.


API

initTranslations(translations, options)

translations

Translation sources keyed by locale. Each locale can provide translations as a static object, a lazy loader, or an async function that fetches translations.

options

| Option | Description | | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fallbackLocale (required) | Locale to use when the requested locale is unavailable. | | localeStorage | Controls how the selected locale is persisted. Defaults to getLocaleLocalStorage("local"). You can provide your own implementation (f.e., a cookie-based solution) as long as it conforms to the LocaleStorage interface. | | onError | Global error handler. Defaults to console.error. You can replace it with your own error reporting function, such as datadog.addError, Sentry.captureException, or any other compatible handler. |


useTranslation(globalKey?: string)

Arguments

| Option | Description | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | globalKey | A path to a section of the translation dictionary. All translation keys passed to t() will be resolved relative to this path, allowing you to avoid repeating common prefixes. |

Returns:

| Variable | Description | | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | locale | The currently active locale. | | setLocale(nextLocale: string) | Sets the active locale. | | isLoading | Indicates whether translations for the current locale are being loaded asynchronously. Use this to display a loading state in your UI. | | t(key: string, variables?: Record<string, ReactNode \| ((content: ReactNode) => ReactNode>)) | Returns the translated string for the given key. If the translation contains variables, they are replaced with the values provided in variables. |


Initial SSR state

To avoid loading dictionaries on the first render:

<TranslationProvider
    initialState={{
        locale: "en",
        dict: dictionary,
    }}
>
    <App />
</TranslationProvider>