Brail is a framework built on NextJS for developing email templates in React, and returning HTML that is compatible with major email clients.

Related tags

Frameworks brail
Overview

Brail

Brail

Transactional email that feels different

License Stars React Core Mjml

Brail is a framework built on NextJS for developing email templates in React, and returning HTML that is compatible with major email clients. It aims to seperate the concerns of generating the emails and delivering them.

In a few lines of code, Brail lets you turn a nextjs app into an email templating server.

💌 Preview emails

📤 Regular deploying to vercel, netlify etc.

📫 JSX templating

📦 Leaves email delivery up to you

Brail is currently in Alpha, and may receive breaking changes at any time.


Installation

# npm i / yarn add / pnpm add
@brail/core @brail/react @brail/mjml

Usage example

pages/product-template.tsx:

{p.name} ); })} ); }; // Create template and defined meta const ProductsTemplate = createTemplate(ProductsTemplateComponent, { name: '/products/new', generateMeta: (props) => ({ subject: `${props.products.length} new products!`, }), previewData: { products: [ { name: 'iPhone 4' }, { name: 'iPhone 8' }, { name: 'iPhone 16' }, ], }, }); export default ProductsTemplate; // Expose page to Nextjs">
// (Optionally) define props
export type ProductsTemplateProps = {
  products: Array<{ name: string; price: string }>;
};

// Create template component
const ProductsTemplateComponent = (props: ProductsTemplateProps) => {
  return (
    <EmailTemplate>
      <MyHeader />
      <Container paddingTop={100} color={theme.red}>
        {props.products.map((p) => {
          return (
            <Row>
              <Column>
                <Text variant="h3">{p.name}</Text>
              </Column>
            </Row>
          );
        })}
      </Container>
      <MyFooter />
    </EmailTemplate>
  );
};

// Create template and defined meta
const ProductsTemplate = createTemplate(ProductsTemplateComponent, {
  name: '/products/new',
  generateMeta: (props) => ({
    subject: `${props.products.length} new products!`,
  }),
  previewData: {
    products: [
      { name: 'iPhone 4' },
      { name: 'iPhone 8' },
      { name: 'iPhone 16' },
    ],
  },
});

export default ProductsTemplate; // Expose page to Nextjs

pages/api/[...email].ts:

import { createServer } from '@brail/core/server';

// Register template so it can be generated via API
export default createServer([ProductsTemplate]);

Then consume the emails via API, dynamically generating transactional content

curl -X POST --data <email_data> <host>/api/products/new | email-sender

Motivation

Brail was created so I never have to use a drag-and-drop editor again. It puts emails back into the "coding ecosystem" where theming, composition and dynamically generating content are standard. Version control? Git. Consistent theming and composition? React components. Vendor lock in? No thanks.

With brail, my emails are portable, consistent, easy and more fun to make.

Packages

@brail/core

Contains the underlying framework for creating and serving templates

@brail/react

Contains components which simplifies email markup, built on top of the MailJet Markup Language (MJML).

@brail/mjml

A fork of MJML providing browser compatibility, type safety and React bindings.

Author

Nick Sinclair

Distributed under the MIT license. See LICENSE for more information.

https://github.com/sinclairnick

You might also like...

AngularJS - HTML enhanced for web apps!

AngularJS AngularJS lets you write client-side web applications as if you had a smarter browser. It lets you use good old HTML (or HAML, Jade/Pug and

Jan 4, 2023

The worlds smallest fully-responsive css framework

FLUIDITY A fully responsive css framework that is impossibly small HTML is almost 100% responsive out of the box. This stylesheet patches the remainin

Sep 24, 2022

One framework. Mobile & desktop.

One framework. Mobile & desktop.

Angular - One framework. Mobile & desktop. Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScr

Jan 4, 2023

Ember.js - A JavaScript framework for creating ambitious web applications

Ember.js - A JavaScript framework for creating ambitious web applications

Ember.js is a JavaScript framework that greatly reduces the time, effort and resources needed to build any web application. It is focused on making yo

Jan 8, 2023

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Supporting Vue.js Vue.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome ba

Jan 8, 2023

The tiny framework for building hypertext applications.

Hyperapp The tiny framework for building hypertext applications. Do more with less—We have minimized the concepts you need to learn to get stuff done.

Jan 4, 2023

The Backbone Framework

Marionette.js The Backbone Framework Marionette v5 Marionette is dropping its dependency on Backbone. That library is available here: https://github.c

Jan 5, 2023

A JavaScript Framework for Building Brilliant Applications

mithril.js What is Mithril? Installation Documentation Getting Help Contributing What is Mithril? A modern client-side JavaScript framework for buildi

Dec 26, 2022

Better MV-ish Framework

Better MV-ish Framework

❗ I started working on this project in 2012. React didn't exist, Angular didn't have a stable 1.0 release, Internet Explorer 7, 8, 9 was used by 35% o

Jan 1, 2023
Comments
  • Attempts to fix `/docs` 404 flash.

    Attempts to fix `/docs` 404 flash.

    There's a brief flash of a 404 on the /docs site.

    CleanShot 2022-11-10 at 09 17 44

    After doing some digging, I'd like to try this solution to see if it goes away.

    Fair warning... This may or may not work, but I'll clean up after myself if it doesn't. 😊

    If you allow this to deploy to a Vercel preview url, we should be able to test it before merging to ensure it works.

    opened by manovotny 4
Owner
null
NativeScript empowers you to access native api's from JavaScript directly. Angular, Vue, Svelte, React and you name it compatible.

NativeScript empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile de

NativeScript 22k Jan 4, 2023
HTML Framework that allows you not to write JavaScript code.

EHTML (or Extended HTML) can be described as a set of custom elements that you can put on HTML page for different purposes and use cases. The main ide

Guseyn Ismayylov 171 Dec 29, 2022
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.

?? Welcome to DataFormsJS! Thanks for visiting! ?? ?? ?? ?? ?? ?? 中文 (简体) 欢迎来到 DataFormsJS Español Bienvenido a DataFormsJS Português (do Brasil) Bem

DataFormsJS 156 Dec 8, 2022
A framework for building native apps with React.

React Native Learn once, write anywhere: Build mobile apps with React. Getting Started · Learn the Basics · Showcase · Contribute · Community · Suppor

Facebook 106.8k Jan 3, 2023
An HTML5/CSS3 framework used at SAPO for fast and efficient website design and prototyping

Welcome to Ink Ink is an interface kit for quick development of web interfaces, simple to use and expand on. It uses a combination of HTML, CSS and Ja

SAPO 1.9k Dec 15, 2022
A framework for real-time applications and REST APIs with JavaScript and TypeScript

A framework for real-time applications and REST APIs with JavaScript and TypeScript Feathers is a lightweight web-framework for creating real-time app

Feathers 14.2k Dec 28, 2022
MVC framework making it easy to write realtime, collaborative applications that run in both Node.js and browsers

Derby The Derby MVC framework makes it easy to write realtime, collaborative applications that run in both Node.js and browsers. Derby includes a powe

DerbyJS 4.7k Dec 31, 2022
An open-source, self-hosted, low-code framework to build internal tools, web apps, admin panels, BI dashboards, workflows, and CRUD apps with YAML or JSON.

An open-source, self-hosted, low-code framework to build internal tools, web apps, admin panels, BI dashboards, workflows, and CRUD apps with YAML or JSON.

Lowdefy 2k Jan 4, 2023
Supabase client initialization and encapsulation in fastify framework

fastify-supabase Supabase client initialization and encapsulation in fastify framework. Install Install the package with: npm i fastify-supabase --sav

null 19 Aug 2, 2022