nuxt-i18n-micro
nuxt-i18n-micro

I18n Micro is a fast, simple, and lightweight internationalization (i18n) module.

npm versionnpm downloadsLicenseDonate

logo

Nuxt I18n Micro

Nuxt I18n Micro is a fast, simple, and lightweight internationalization (i18n) module for Nuxt. Despite its compact size, it's designed with large projects in mind, offering significant performance improvements over traditional i18n solutions like nuxt-i18n. The module was built from the ground up to be highly efficient, focusing on minimizing build times, reducing server load, and shrinking bundle sizes.

Why Nuxt I18n Micro?

The Nuxt I18n Micro module was created to address critical performance issues found in the original nuxt-i18n module, particularly in high-traffic environments and projects with large translation files. Key issues with nuxt-i18n include:

  • High Memory Consumption: Consumes significant memory during both build and runtime, leading to performance bottlenecks.
  • Slow Performance: Especially with large translation files, it causes noticeable slowdowns in build times and server response.
  • Large Bundle Size: Generates a large bundle, negatively impacting application performance.
  • Memory Leaks and Bugs: Known for memory leaks and unpredictable behavior under heavy load.

Performance Comparison

To showcase the efficiency of Nuxt I18n Micro, we ran the same fixture suite via pnpm test:performance (pnpm -C scripts cli performance) against @nuxtjs/i18n@10.6.0 on the same hardware. We also include a plain-nuxt baseline (no i18n module) to measure the real overhead.

Build Time and Resource Consumption

Note: The plain-nuxt baseline is a minimal implementation created solely for benchmarking purposes. It loads data directly from JSON files without any i18n logic. Latest run: @nuxtjs/i18n@10.6.0, mean of 3 consecutive runs per fixture, default CLI profile (~16.8k index leaves).

ProjectBuild TimeCode BundleMax MemoryMax CPU
plain-nuxt (baseline)5.32s1.53 MB810 MB207%
i18n-micro5.34s1.74 MB1,065 MB204%
@nuxtjs/i18n v10.68.34s2.16 MB1,821 MB204%

Code Bundle = JS/CSS only (excludes classified translation payloads, including @nuxtjs/i18n chunks/raw/*). Older tables that showed ~15 MB โ€œcodeโ€ for v10.6 were counting message chunks as app code.

  • i18n-micro vs baseline: โ‰ˆ same build time, +0.21 MB code, +255 MB peak RSS
  • @nuxtjs/i18n v10.6 vs baseline: +3.02s build, +0.63 MB code, +1,011 MB peak RSS

Stress Test Results (Requests per Second)

ProjectAvg Response (Artillery)RPS (Artillery)RPS (Autocannon)Avg Latency (AC)
plain-nuxt1,194 ms10965152 ms
i18n-micro483 ms27516262 ms
@nuxtjs/i18n v10.6956 ms14372139 ms

Comparison: @nuxtjs/i18n v10.6 vs i18n-micro

  • Code Bundle: 0.42 MB smaller (1.74 MB vs 2.16 MB)
  • Build Time: 3.00s faster (5.34s vs 8.34s)
  • Max Memory (build): 756 MB less (1,065 MB vs 1,821 MB)
  • Average Response Time (Artillery): 473 ms faster (483 ms vs 956 ms)
  • Requests Per Second (Artillery): 132 more (275 vs 143)

Micro leads on build cost and especially under load. See the full benchmark report for methodology and charts.

Key Features

  • ๐ŸŒ Compact Yet Powerful: Despite its small size, Nuxt I18n Micro is designed for large-scale projects, focusing on performance and efficiency.
  • โšก Optimized Build and Runtime: Reduces build times, memory usage, and server load, making it ideal for high-traffic applications.
  • ๐Ÿ›  Minimalist Design: The module core is a single Nuxt module plus a small set of runtime plugins, making it easy to understand, extend, and maintain.
  • ๐Ÿ“ Strategy-Based Routing: Locale prefixes are handled via @i18n-micro/route-strategy (build-time) and @i18n-micro/path-strategy (runtime), with strategies such as prefix, no_prefix, prefix_except_default, and prefix_and_default.
  • ๐Ÿ—‚ Streamlined Translation Loading: Only JSON files are supported, with translations split between a global file for common texts (e.g., menus) and page-specific files, which are auto-generated in the dev mode if not present.

Quick Setup

Install the module in your Nuxt application with:

npm install nuxt-i18n-micro

Then, add it to your nuxt.config.ts:

export default defineNuxtConfig({
  modules: [
    'nuxt-i18n-micro',
  ],
  i18n: {
    locales: [
      { code: 'en', iso: 'en-US', dir: 'ltr' },
      { code: 'fr', iso: 'fr-FR', dir: 'ltr' },
      { code: 'ar', iso: 'ar-SA', dir: 'rtl' },
    ],
    defaultLocale: 'en',
    translationDir: 'locales',
    meta: true,
  },
})

That's it! You're now ready to use Nuxt I18n Micro in your Nuxt app.

Star History

Star History Chart

Docs

Plugin Methods

Performance

Performance Test Results

Components

Layers

Seo

Migration

Contribution