Better I18NBetter I18N
Next.js

Configuration

All configuration options for @better-i18n/next

The createI18n function is the entry point for the SDK. It accepts a configuration object that defines your project context and delivery preferences.

Basic Configuration

The absolute minimum required is your project indentifier and default locale.

i18n.config.ts
import { createI18n } from "@better-i18n/next";

export const i18n = createI18n({
  project: "your-org/your-project",
  defaultLocale: "en",
});

The project value uses org/project format. This same value is used by the CLI and MCP to identify your project.

You can also configure CLI-specific options (like linting rules and file exclusions) in this same file. See CLI Configuration for details.

Full Reference

OptionTypeDefaultDescription
projectstringrequiredProject identifier in org/project format
defaultLocalestringrequiredDefault/fallback locale code
cdnBaseUrlstringautoCDN base URL (auto-detected)
localePrefix"as-needed" | "always" | "never""as-needed"URL locale prefix behavior
debugbooleanfalseEnable debug logging
logLevelLogLevel"warn"Logging verbosity
manifestCacheTtlMsnumber300000Manifest cache TTL in ms
manifestRevalidateSecondsnumber3600Next.js revalidate for manifest
messagesRevalidateSecondsnumber30Next.js revalidate for messages
cookieNamestring"locale"Name of the locale persistence cookie
timeZonestringSystem tzIANA timezone. Set explicitly to avoid ENVIRONMENT_FALLBACK warnings and prevent SSR/client hydration mismatches.
storageTranslationStoragePersistent storage adapter (offline fallback)
staticDataRecord<string, Messages> | (() => Promise<...>)Last-resort bundled translations for offline use
fetchTimeoutnumber10000CDN fetch timeout in ms
retryCountnumber1Retry attempts on CDN failure

Behavior Customization

Control how locales appear in your URLs.

// /page for default, /tr/page for others
createI18n({ project: "org/project", defaultLocale: "en", localePrefix: "as-needed" });

// always includes locale: /en/page, /tr/page
createI18n({ project: "org/project", defaultLocale: "en", localePrefix: "always" });

// never includes locale in URL
createI18n({ project: "org/project", defaultLocale: "en", localePrefix: "never" });

Configure TTL for edge and runtime caching.

createI18n({
  project: "org/project",
  defaultLocale: "en",
  // Cache manifest in memory for 5 minutes
  manifestCacheTtlMs: 5 * 60 * 1000,

  // Next.js ISR revalidation times
  manifestRevalidateSeconds: 3600,
  messagesRevalidateSeconds: 30,
});

Enable detailed logging for troubleshooting.

createI18n({
  project: "org/project",
  defaultLocale: "en",
  debug: true,
  logLevel: "debug",
});

On this page