{"_id":"@alturacode/lingua-react","_rev":"2-69513d32e36ca994df519671292ec11e","name":"@alturacode/lingua-react","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@alturacode/lingua-react","version":"0.1.0","keywords":["i18n","translations","internationalization","react","lazy","fallback"],"license":"MIT","_id":"@alturacode/lingua-react@0.1.0","maintainers":[{"name":"gerardojbaez","email":"g@gerardobaez.com"}],"dist":{"shasum":"25a9fd31879893d2e2c6e585f1209f2b1a61d6be","tarball":"https://registry.npmjs.org/@alturacode/lingua-react/-/lingua-react-0.1.0.tgz","fileCount":8,"integrity":"sha512-Ly0lJuxXP+/EyQuxBs+ADbuJ1lQmOnYqm9Gk28orR4UkF5442lAyb61BVlqAZDr5zfTfInW0CuxbsNP+YMzpXg==","signatures":[{"sig":"MEUCIQCOtadhWv1t6vDKVmiiR4ki+AeQbtn8KmqTHi8jzlO5RwIgTN50HB2X+1/IKXxDbzSakoPewgWOPbtT+IfuQvJEADk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15419},"main":"./dist/index.cjs","type":"module","_from":"file:alturacode-lingua-react-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"gerardojbaez","email":"g@gerardobaez.com"},"_resolved":"/private/var/folders/bq/hn_32rl50xz_h42dns80hkjm0000gn/T/27f045276a5f1133b05a5bec409db7d3/alturacode-lingua-react-0.1.0.tgz","_integrity":"sha512-Ly0lJuxXP+/EyQuxBs+ADbuJ1lQmOnYqm9Gk28orR4UkF5442lAyb61BVlqAZDr5zfTfInW0CuxbsNP+YMzpXg==","_npmVersion":"10.9.2","description":"React bindings for @alturacode/lingua.","directories":{},"_nodeVersion":"23.8.0","dependencies":{"@alturacode/lingua":"0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","jsdom":"^26.0.0","react":"^19.2.0","vitest":"^3.0.5","react-dom":"^19.2.0","typescript":"^5.7.2","@types/react":"^19.2.0","@testing-library/react":"^16.2.0"},"peerDependencies":{"react":">=19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/lingua-react_0.1.0_1785739449752_0.19464646576210987","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@alturacode/lingua-react","version":"0.1.1","description":"React bindings for @alturacode/lingua.","keywords":["i18n","translations","internationalization","react","lazy","fallback"],"license":"MIT","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"dependencies":{"@alturacode/lingua":"0.1.1"},"peerDependencies":{"react":">=19.0.0"},"devDependencies":{"@testing-library/react":"^16.2.0","@types/react":"^19.2.0","jsdom":"^26.0.0","react":"^19.2.0","react-dom":"^19.2.0","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^3.0.5"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest"},"_id":"@alturacode/lingua-react@0.1.1","_integrity":"sha512-I6JQuGin4fH9ir7QQkgJhefoNaOIXO35kpl5qrIAldsknn9gmKhPdZiWHQyWyL8EYAaEdOSAONLA9h+vvQDYmw==","_resolved":"/private/var/folders/bq/hn_32rl50xz_h42dns80hkjm0000gn/T/bf4c41c12e719babdc89a96885eb0867/alturacode-lingua-react-0.1.1.tgz","_from":"file:alturacode-lingua-react-0.1.1.tgz","_nodeVersion":"23.8.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-I6JQuGin4fH9ir7QQkgJhefoNaOIXO35kpl5qrIAldsknn9gmKhPdZiWHQyWyL8EYAaEdOSAONLA9h+vvQDYmw==","shasum":"43735b2d19876b68bbe275e9163ef1a1a3921071","tarball":"https://registry.npmjs.org/@alturacode/lingua-react/-/lingua-react-0.1.1.tgz","fileCount":9,"unpackedSize":19085,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHMxIb2r/4+tOW+Q5uD7d/9VYVHSYLwOMxnxgkeBpKQPAiBe7iyNVyq/Al6hPDOkaU+LULuVfggP6pDIlNbQ2x3paQ=="}]},"_npmUser":{"name":"gerardojbaez","email":"g@gerardobaez.com"},"directories":{},"maintainers":[{"name":"gerardojbaez","email":"g@gerardobaez.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lingua-react_0.1.1_1785772998404_0.031740340527643296"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-03T06:44:09.561Z","modified":"2026-08-03T16:03:18.718Z","0.1.0":"2026-08-03T06:44:09.896Z","0.1.1":"2026-08-03T16:03:18.545Z"},"license":"MIT","keywords":["i18n","translations","internationalization","react","lazy","fallback"],"description":"React bindings for @alturacode/lingua.","maintainers":[{"name":"gerardojbaez","email":"g@gerardobaez.com"}],"readme":"# @alturacode/lingua-react\n\nReact bindings for [Lingua](https://github.com/alturacode/lingua), the\nframework-agnostic, lazy i18n library. Built on React 19's `use()`.\n\nShip a fully-typed base-locale fallback and lazily `import()`-ed partial\noverrides per locale. Locales without a loader render the fallback\n**synchronously**; other locales suspend while their chunk loads.\n\n```tsx\nimport { LocaleProvider, useTranslations } from '@alturacode/lingua-react';\nimport { Suspense } from 'react';\nimport { translations } from './faq';\n\nfunction Faq() {\n    const t = useTranslations(translations);\n\n    return <h1>{t.title}</h1>;\n}\n\n// For non-base locales, wrap consumers in a Suspense boundary:\n<Suspense fallback={null}>\n    <Faq />\n</Suspense>;\n```\n\n## Install\n\n```bash\npnpm add @alturacode/lingua-react @alturacode/lingua\n```\n\nRequires **React >= 19**. The framework-agnostic core is a peer dependency;\nlocale modules are bundled with it via `createComponentTranslations`.\n\n## The idea\n\nDefine translations as plain objects. The base locale exports the complete,\ntyped shape:\n\n```ts\n// faq.en.ts\nexport default {\n    title: 'Frequently asked questions',\n    items: [{ question: 'How does billing work?', answer: 'You pay upfront.' }],\n};\n```\n\nOther locales only override what differs, and are checked against the base:\n\n```ts\n// faq.es.ts\nimport type en from './faq.en';\n\nexport default {\n    title: 'Preguntas frecuentes',\n    items: [\n        {\n            question: '¿Cómo funciona el cobro?',\n            answer: 'Pagas por adelantado.',\n        },\n    ],\n} satisfies typeof en;\n```\n\nBundle them with a loader map at module scope:\n\n```ts\n// faq.ts\nimport { createComponentTranslations } from '@alturacode/lingua';\nimport en from './faq.en';\n\nexport const translations = createComponentTranslations(en, {\n    es: () => import('./faq.es'),\n});\n```\n\n## Usage\n\nWrap your app in a `LocaleProvider` once — the locale is a plain string, so it\ncan come from Inertia page props, Next `params`, a cookie, or anything else:\n\n```tsx\nimport { LocaleProvider } from '@alturacode/lingua-react';\n\nfunction App() {\n    return (\n        <LocaleProvider locale={page.props.locale ?? 'en'}>\n            {/* your app */}\n        </LocaleProvider>\n    );\n}\n```\n\nConsume translations anywhere with `useTranslations`:\n\n```tsx\nimport { Suspense } from 'react';\nimport { useTranslations } from '@alturacode/lingua-react';\nimport { translations } from './faq';\n\nfunction Faq() {\n    const t = useTranslations(translations);\n\n    return <h1>{t.title}</h1>;\n}\n\n// For non-base locales:\n<Suspense fallback={null}>\n    <Faq />\n</Suspense>;\n```\n\n## API\n\n### `LocaleProvider({ locale, children })`\n\nProvides the active locale to the tree. The locale is a plain string and can be\nchanged at any time.\n\n### `useLocale(): string`\n\nReturns the active locale, or throws if used outside a `LocaleProvider`.\n\n### `useTranslations<T>(options: TranslationOptions<T>): T`\n\nReturns the translations for the active locale. Loaded modules are memoized in a\nmodule-level cache keyed by the loader, so switching locales back and forth does\nnot re-fetch.\n\n## Behavior\n\n| Locale                    | Behavior                                                          |\n| ------------------------- | ----------------------------------------------------------------- |\n| Base locale / no loader   | Returns the fallback synchronously.                               |\n| Other locale, first visit | Suspends until the chunk loads, then renders merged translations. |\n| Failed or missing module  | Resolves to the fallback.                                         |\n\n## License\n\nMIT — see [LICENSE](../LICENSE).\n","readmeFilename":"README.md"}