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

nodemailer-mjml-i18next-compiler

v0.1.1

Published

Nodemailer compile plugin integrating MJML templating with i18next translations (Handlebars-based)

Readme

Nodemailer MJML i18next Compiler

Docs npm npm downloads

  • Purpose: Nodemailer compile plugin that renders MJML templates with Handlebars and i18next translations.
  • Why: Write responsive emails in MJML, keep copy in i18next JSON files, and inject dynamic data via Handlebars.

Install

  • npm i nodemailer mjml i18next i18next-fs-backend handlebars
  • Add this plugin as a dependency of your project (copy this folder or publish and npm i nodemailer-mjml-i18next-compiler).
  • Install from npm: https://www.npmjs.com/package/nodemailer-mjml-i18next-compiler

Usage

const nodemailer = require('nodemailer');
const { mjmlI18nextCompiler } = require('nodemailer-mjml-i18next-compiler');

const transporter = nodemailer.createTransport({ /* SMTP config */ });

transporter.use('compile', mjmlI18nextCompiler({
  templatesDir: path.join(__dirname, 'templates'),
  partialsDir: path.join(__dirname, 'templates', 'partials'),
  localesDir: path.join(__dirname, 'locales'),
  defaultLocale: 'en',
  namespaces: ['common', 'emails'],
  defaultNamespace: 'common',
  mjmlOptions: { validationLevel: 'soft' },
  strict: false, // set true to error on MJML warnings
}));

await transporter.sendMail({
  from: '[email protected]',
  to: '[email protected]',
  template: 'welcome',           // resolves templates/welcome.mjml.hbs
  locale: 'en',
  context: { name: 'Taylor' },   // handlebars + i18next interpolation data
  // subject: 'Custom subject',
  // subjectKey: 'emails:welcome.subject',
});

Templates

  • Place templates under templatesDir. The resolver tries in order:
    • <name>.mjml.hbs
    • <name>.hbs.mjml
    • <name>.mjml
    • <name>.hbs

Inside templates, you can use Handlebars and the t helper for translations:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text font-size="20px">{{t "emails:welcome.title" name=name}}</mj-text>
        <mj-text>{{t "common:greeting" name=name}}</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
  
</mjml>

i18next

  • By default, the plugin initializes its own i18next instance with i18next-fs-backend and loads from locales/<lng>/<ns>.json.
  • Provide your own initialized instance via i18next option to integrate with an existing i18next setup.
  • In templates, {{t "key"}} and {{__ "key"}} are available. Locale is taken from mail.data.locale.

Options

  • templatesDir: Absolute path to MJML/Handlebars templates. Required.
  • partialsDir: Optional absolute path to Handlebars partials.
  • localesDir: Absolute path to i18next locales folder. Default: locales.
  • defaultLocale: Fallback language. Default: en.
  • namespaces: i18next namespaces to use. Default: ["common"].
  • defaultNamespace: Default i18next namespace. Default: "common".
  • preload: Locales to preload. Default: [defaultLocale].
  • mjmlOptions: Options passed to mjml().
  • autoSubject: If no subject and translation exists at emails.<template>.subject, use it. Default: true.
  • subjectNamespace: Namespace for auto-subject lookup (uses <subjectNamespace>:<template>.subject). Default: "emails".
  • helpers: Object map of extra Handlebars helpers to register.
  • force: Recompile even if mail.data.html already exists. Default: false.
  • strict: Throw error when MJML reports errors. Default: false.

TypeScript

  • Types are included via src/index.d.ts.
  • Import styles:
    • CommonJS: const { mjmlI18nextCompiler } = require('nodemailer-mjml-i18next-compiler')
    • ESM/TS: import { mjmlI18nextCompiler } from 'nodemailer-mjml-i18next-compiler'
    • Options type: import type { MjmlI18nextOptions } from 'nodemailer-mjml-i18next-compiler'

Mail Data

  • template: Template base name (without extension). Required if html is absent.
  • context (or locals): Data for Handlebars and i18next interpolation.
  • locale: Locale for translations (e.g., en, fr).
  • subjectKey: Optional i18next key for subject. If missing and autoSubject is enabled, uses emails.<template>.subject if defined.

Example Project Layout

project/
  locales/
    en/
      common.json
      emails.json
  templates/
    welcome.mjml.hbs
    partials/
      footer.mjml.hbs

Notes

  • The plugin compiles Handlebars first to produce MJML, then compiles MJML to HTML.
  • You can access t/__ both as helpers and as functions in context.
  • If you need plain-text generation, add it downstream (e.g., html-to-text).

Documentation

  • GitHub Pages: https://xjodoin.github.io/nodemailer-mjml-i18next-compiler/
  • Docs source: mkdocs.yml and docs/ in the repo.
  • LLM context: https://xjodoin.github.io/nodemailer-mjml-i18next-compiler/llms.txt
  • LLM full context: https://xjodoin.github.io/nodemailer-mjml-i18next-compiler/llms-full.txt

Contributors

  • Primary author: Xavier Jodoin
  • See all contributors: https://github.com/xjodoin/nodemailer-mjml-i18next-compiler/graphs/contributors

License

  • MIT — see LICENSE for details.