Core API

createI18n

createI18n is the entry point of pico-intl. It returns a fully configured i18n instance with all translation, locale, and event methods.

ts
const i18n = await createI18nAsync({
  base: 'en',
  locale: 'auto',
  supported: ['en', 'es'],
  messages: en,
  loader: (locale) => import(`./locales/${locale}.json`),
});

Key points

  • Use createI18n() when messages are already available synchronously.
  • Use createI18nAsync() when detection or initial loading must finish before render.
  • Pass supported locales when using locale: auto.

Next step

Copy the example into a small fixture, run the validation commands, and keep framework-specific routing, hydration, or SSR behavior covered by your app tests.