Skip to main content

Server side render

This section explains how to use Easy Email Pro's server-side rendering capabilities. However, it's important to note that you are not required to use Easy Email Pro's dynamic rendering engine. If your company already has its own template tag replacement system, you can continue using that system and skip this section.

When to use this guide​

Use this guide if you want to:

  • Leverage Easy Email Pro's built-in dynamic rendering capabilities
  • Generate HTML that includes dynamic content from Easy Email Pro templates

If you only need to generate static HTML from your templates and will handle dynamic content replacement with your own system, you can simply use the toMJML and mjml conversion functions without the plugin rendering step.

Server-side rendering with Easy Email Pro​

Register plugins (If you need these plugins)​

PluginManager.registerPlugins([Countdown, Shopwindow]);

Register custom blocks​

BlockManager.registerBlocks([DynamicCustomBlock]);
const main = async () => {
await EditorCore.auth(process.env.CLIENT_ID!);

const pageData = template.content as EmailTemplate["content"];

// mjmlSkeleton & htmlSkeleton can be cached
const mjmlSkeleton = EditorCore.toMJML({
element: pageData,
mode: "production",
});
const htmlSkeleton = mjml(mjmlSkeleton).html;

const finalHtml = PluginManager.renderWithData(htmlSkeleton, {});

console.log(finalHtml);
};

main();

Using your own template system​

If you prefer to use your own template system:

  1. Generate the HTML from Easy Email Pro templates using toMJML and mjml
  2. Skip the PluginManager.renderWithData step
  3. Pass the generated HTML to your own template engine to replace variables and dynamic content

This approach allows you to integrate Easy Email Pro's design capabilities with your existing template processing system.

AMP Email and server-side rendering​

If your template uses AMP blocks (e.g. Accordion, Carousel, Form, Product, Reviews, Lucky Wheel), the server-side flow differs from the standard HTML path:

  • Export MJML with outputFormat: "amp-mjml" (see AMP Block).
  • Convert to final HTML with mjml2amp (not the regular mjml package). AMP requires explicit width/height for images, so you must resolve image dimensions (e.g. via getImageUrlsForAmp and your own dimension lookup) before calling mjml2amp.

For details on registering AMP plugins, outputFormat, image dimensions, and Form/Reviews backends, see AMP Block.