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

@venkateshmedipudi/react-i18n-lite

v1.0.1

Published

A lightweight React i18n and localization library for effortless multi-language support.

Readme

@venkateshmedipudi/react-i18n-lite

Lightweight internationalisation (i18n) utilities for React applications with built-in locale detection, memoised translations, and locale-aware formatting.

✨ Features

  • 🔤 Context-based translation provider with intuitive useI18n() hook
  • 🌐 Automatic browser language detection with configurable fallback
  • ⚙️ Optional async locale loader for code-splitting translation bundles
  • 🧮 Locale-aware date, number, and currency helpers via useLocaleFormatter()
  • 🧠 Helpful warnings for missing keys and full TypeScript typings
  • 🚀 Ready-to-publish build with ESM + CJS outputs and Jest test suite

📦 Installation

npm install @venkateshmedipudi/react-i18n-lite
# or
yarn add @venkateshmedipudi/react-i18n-lite
# or
pnpm add @venkateshmedipudi/react-i18n-lite

Peer dependency: react >= 18. Install it separately if it is not already part of your project.

🚀 Quick Start

import { I18nProvider, useI18n } from "@venkateshmedipudi/react-i18n-lite";

const resources = {
  en: { welcome: "Welcome, {{name}}!" },
  es: { welcome: "¡Bienvenido, {{name}}!" }
};

function Home() {
  const { t, setLocale } = useI18n();

  return (
    <div>
      <h1>{t("welcome", { name: "Venkatesh" })}</h1>
      <button onClick={() => setLocale("es")}>Switch to Spanish</button>
    </div>
  );
}

export default function App() {
  return (
    <I18nProvider defaultLocale="en" resources={resources}>
      <Home />
    </I18nProvider>
  );
}

🛠 API Reference

<I18nProvider>

| Prop | Type | Default | Description | | --- | --- | --- | --- | | defaultLocale | string | — | Locale used when detection fails or no resource exists. | | resources | Record<string, Record<string, string>> | {} | Translation dictionaries keyed by locale. | | detectBrowserLocale | boolean | true | Use browser language if supported. | | loadLocale | (locale: string) => Promise<Record<string, string>> | undefined | Lazy-load messages for locales not bundled initially. | | onMissingKey | ({ key, locale }) => void | undefined | Called when a translation key is not found. |

useI18n()

Returns:

{
  t: (key: string, vars?: Record<string, unknown>) => string;
  setLocale: (locale: string) => Promise<void>;
  locale: string;
  availableLocales: string[];
  isLoading: boolean;
}
  • t interpolates placeholders like {{name}}.
  • setLocale triggers async loading when loadLocale is supplied.
  • availableLocales reflects all loaded resource keys.

useLocaleFormatter()

Locale-aware wrappers around the built-in Intl APIs using the active locale from useI18n():

const { formatDate, formatNumber, formatCurrency } = useLocaleFormatter();

formatDate(new Date()); // e.g. "13 Nov 2025"
formatNumber(1234567.89); // e.g. "1,234,567.89"
formatCurrency(209537500, "INR"); // e.g. "₹2,09,53,750.00"

Async Locale Loading

Pass a loadLocale function to lazy-load dictionaries:

<I18nProvider
  defaultLocale="en"
  resources={{ en: baseMessages }}
  loadLocale={(locale) => import(`./locales/${locale}.json`).then((m) => m.default)}
>
  <App />
</I18nProvider>

When setLocale("es") is called, the loader resolves translations and caches them.

🧪 Testing

npm test
  • tests/i18n.test.tsx — verifies translation rendering, locale switching, fallbacks, and async loading
  • tests/formatter.test.ts — covers number/date/currency formatting and locale updates

🧱 Project Scripts

| Command | Description | | --- | --- | | npm run build | Builds ESM & CJS bundles with Vite + Rollup. | | npm run test | Executes Jest + React Testing Library suite. | | npm run lint | Runs TypeScript type-check with tsc --noEmit. | | npm run publish:package | Convenience wrapper for npm publish --access public. |

🧑‍💻 Contributing

  1. Fork the repository and clone your fork.
  2. Install dependencies with npm install.
  3. Run npm run test and npm run lint before submitting a PR.
  4. Describe your changes in the PR template and link any relevant issues.

Issues and feature requests are welcome—feel free to open a discussion before large changes.

🔗 Example Project

A sample integration is available at: https://github.com/venkateshmedipudi/react-i18n-lite-example

📄 License

Released under the MIT License.