Skip to main content

Basic Setup

To start, install the package:
Minimal supported React version is 18.2.0.
Import the required components and styles:
Use the components in your app:
The TemplateProvider creates the template automatically if it does not already exist.

Authentication

The token prop on TemplateProvider accepts a JWT issued by the Courier API. Generate this token server-side and pass it to your frontend; never expose your API key in the browser.
The example above grants access to all tenants. To restrict the token to a single tenant, use tenant-scoped scopes like tenant:tenant-123:read instead. See the Authentication page for the full list of available scopes.

Publishing Hook

Users can override the default publish button with custom logic:

Theming Support

You can customize the editor’s appearance using the theme prop:

Disabling Auto-Save

By default, the Courier Create editor auto-saves content. To disable this feature, configure the provider as follows:

Restricting Visible Channels

You can restrict which channels appear in the template editor by using the routing.channels prop. This is useful when your application only uses specific channels (e.g., email-only workflows). To show only email (hiding Slack, SMS, push, etc.):
The channels array controls which channels appear in the editor - any channels not in that array will be hidden. You can include multiple channels if needed:
The method property controls delivery strategy:
  • "single" - delivers via first available channel (fallback routing)
  • "all" - delivers via all configured channels simultaneously
Available channel values: "email", "sms", "push", "inbox", "slack", "msteams"

Switching Templates Dynamically

If your application lets users select which template to edit (for example, from a dropdown or list), pass the selected template ID to TemplateProvider. The provider creates templates automatically if they don’t exist, so you don’t need to check beforehand.
The key prop on TemplateProvider forces React to remount the component when the template changes. Without it, the editor may show stale content from the previous template because the internal state does not fully reset on prop changes alone.
Always include the key prop when templateId changes dynamically. This applies whether the editor is on a regular page, inside a modal, or in any other context.

Using in Modals and Dialogs

Courier Create works inside modals and dialogs. The same key prop pattern applies; React portals (used by most modal libraries) can prevent proper state updates when props change.

Using Variables

Variables are placeholders in your template that get replaced with actual data when the email is sent. For example, instead of writing Hello customer you can write Hello {{user.firstName}}, which will display the recipient’s actual name. The Courier Embeddable editor supports nested variable structures:

How to Insert Variables

  1. When editing text, type {{ to open the variable suggestions dropdown. Select the variable you want to insert from the list.
  2. Via curly braces {} icon in top toolbar (if the variables are available for selected element).

Sending a Message

Ensure you include the tenant_id in the message context and template identifier.

Overview

Your sample implementation will look something like this:
Embeddable Designer

Embeddable Designer Preview

Troubleshooting

Template content not updating when switching templates

If the editor shows stale content after changing the templateId prop, add a key prop to TemplateProvider that changes with the template ID:
This forces React to remount the provider and reset its internal state. This issue is most common when the editor is inside a modal or dialog (React portal), but can occur in any context where templateId changes dynamically.

Editor not loading inside a modal

Verify that TemplateProvider receives a valid token when the modal opens. If you generate the JWT lazily, the token may not be ready on first render. Either generate the token before opening the modal or conditionally render the provider: