Skip to main content
Novu Framework workflows are code-first: workflow definitions and content are expressed in code rather than in the dashboard. Internationalization (i18n) is implemented in the application layer - translations are defined there and resolved at runtime - so that workflow step content (e.g. subject and body fields) can be locale-aware. This guide implements a locale-aware email notification workflow using i18next for translation resolution and React Email for the message template, with a Twitch welcome email as the reference implementation.
1

Create translation keys in the code

Import the createInstance and InitOptions from the i18next library and add translation keys for all supported locales.
translations.ts
2

Create email template

  • Create a new file called react-email-template.tsx and add the following code using components from the @react-email/components library.
  • Add the renderEmail function to render the email template.
Here, we are using @react-email/components to build the email template. You can use any other library or bare HTML to build the email template.
react-email-template.tsx
3

Create the workflow and use translations

  • Create the workflow definition by importing the workflow function from the @novu/framework library.
  • Import the renderEmail function from the react-email-template.tsx file. This is the email template that will be used to send the notification.
  • Import the i18n from the translations.ts file.
  • Import the zod library to validate the workflow payload.
workflow-with-translations.ts
4

Add workflow to serve function

api/novu/route.ts
5

Sync and test the workflow

  • Sync the workflow to the Novu cloud.
  • Test the workflow by triggering it to subscribers with different locales.