Skip to main content
The @suprsend/react-editor package provides the UI for embeddable templates: channel editors, preview, test, commit, and theming. You can use this to let your customers edit their notification templates or for your internal team to manage templates and run campaigns within your product. Import the CSS bundle for correct layout and styling.

Installation

You must import the stylesheet (@suprsend/react-editor/styles.css) for the components to render correctly.

Authentication

Provide an accessToken and optionally a refreshAccessToken callback to handle token expiration.
When a 401 response is received, the SDK automatically calls refreshAccessToken, queues pending requests, and retries them with the new token.

Generating access token


Components

SuprSendTemplateProvider

The root context provider. Wrap your editor UI with this component. This is where you configure which template and variant to edit, which channels to enable, theming, and authentication.
Props
For self-hosted deployments, pass prop host={{apiHost:<your-management-api-service-url>}}.

Conditions

Use the conditions prop when you want to specify the variant based on conditions other than tenantId and locale. If your variant is identified solely by tenantId and locale, you don’t need this prop. Conditions can be evaluated against the input payload, tenant, actor, and recipient properties to decide which variant applies. Passing conditions scopes the editor to the variant matching those rules. The shape follows the variant_condition_expr_v1_def definition in the variant schema. conditions is an array of expression objects, where each object has: Each clause in args is a single comparison: All clauses inside a single expression_v1.args are combined with AND. The conditions array itself can hold multiple expression objects to express alternative (OR) audience groups.
Supported operators (op)
If a key’s data type doesn’t match the operator (for example, using > on a string), the condition always evaluates to false.
Example — each object in the conditions array is OR-ed, while the clauses inside one expression_v1.args are AND-ed. The variant below loads when either the order is high-priority for a Pro-plan tenant OR the acting user is an admin sending to a recipient in India:

Supported channels


TemplateEditor

The main editor component. Renders channel tabs, channel editor forms, and preview panes.
Props
When hideActionButtons is true, use the standalone TestButton and CommitButton components to place actions anywhere in your layout.

CommitButton

A button that opens the commit modal. Validates all variants, lets the user select which to publish, and requires a commit message.
Props

TestButton

A button that opens the test modal. Allows sending a test notification to a real recipient with mock data.
Props

Theming

The theme prop (light, dark, system) is coming soon. Customize the look and feel today using themeOverrides.

Available overrides

All CSS classes are scoped with a suprsend- prefix to prevent conflicts with your application’s styles.