@dbx-tools/shared-email-template

中文文档
0.9.206发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 9667

Universal React Email presentation shared by dbx-tools server and browser surfaces

原始使用文档
文档目录6 节
  1. Quick start
  2. Runtime boundary
  3. Configure the template
  4. Reuse the body preview
  5. Apply a brand
  6. Package exports

@dbx-tools/shared-email-template

Render the same React Email presentation in server-delivered messages and browser previews. The package owns the branded document, card, body, and brand mapping without depending on Databricks AppKit, SMTP, or DOM APIs.

Quick start

Render the same branded document in SMTP delivery and browser previews:

import { EmailDocument } from "@dbx-tools/shared-email-template";

<EmailDocument subject="Incident update" body="## Resolved\nAll systems are healthy." />;

The exported components cover:

  • Responsive React Email document with email-safe inline styling.
  • Reusable message-body component for approval and compose previews.
  • dbx-tools branding applied by default through BrandContext.
  • Consumer brand overrides without coupling templates to AppKit or SMTP.
  • Rich content rendered consistently in the inbox and browser.

Runtime boundary

This package provides presentation only:

The package doesn't send messages, approve delivery, access AppKit request identity, or require browser DOM APIs.

Configure the template

import { EmailDocument } from "@dbx-tools/shared-email-template";

<EmailDocument subject="Incident update" body="## Resolved\nAll systems are healthy." />;

Node runtimes should pass this component to @react-email/render. @dbx-tools/email does that automatically for SMTP and local outbox delivery.

heading defaults to the MIME subject. Pass a shorter heading when the subject carries notification-specific details. One-time-code mail uses this to keep the code in notifications without repeating it inside the opened card:

<EmailDocument
  subject="123456 is your verification code"
  heading="Your verification code"
  preview="Your verification code is: 123456"
  body={body}
/>

preview sets the preheader, which is the snippet a client shows beside the subject and the body of the push notification a mobile mail app posts. It defaults to the subject. Set it when the notification should say something the subject does not:

<EmailDocument
  subject="123456 is your verification code"
  preview="Your verification code is: 123456"
  body={body}
/>

Mobile one-time-code autofill can read the code from the notification's sender, subject, and preheader. A code that appears only in the message body doesn't reach the autofill heuristics.

Reuse the body preview

import { EmailBody } from "@dbx-tools/shared-email-template";

<EmailBody body={draft.body} />;

The body preview and complete document share typography and content styling. The full document adds the branded header band, heading, and footer. Envelope rows (headers) are opt-in for local outbox previews. Delivered SMTP mail and browser approval chrome leave recipients and attachments outside the HTML body.

Use EmailCard when a browser surface should show that complete presentation without rendering an outer <html> or <body> element:

import { EmailCard } from "@dbx-tools/shared-email-template";

<EmailCard subject={draft.subject} body={draft.body} />;

Apply a brand

import { brandUtils } from "@dbx-tools/shared-core";
import { emailBrandFromContext } from "@dbx-tools/shared-email-template";

const emailBrand = emailBrandFromContext(brandUtils.defaultBrandContext);

Omitting brand uses the dbx-tools brand. A consumer may supply its own colors, font, name, tagline, website, and fetchable logo URL. The footer renders a tagline only when the supplied brand declares one.

Package exports

  • .: EmailDocument, EmailCard, EmailBody, brand types/defaults, and content normalization.

Pair this package with @dbx-tools/shared-email for wire schemas, @dbx-tools/email for delivery, and @dbx-tools/ui/email for approval and compose UI.

版本与发布记录

@dbx-tools/shared-email-template 共发布 267 个版本,首次发布于 2026/08/03;过去 12 个月发布了 267 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.206latest2026/11/11今天
0.9.2052026/11/111 天前
0.9.2042026/11/101 天前
0.9.2032026/11/074 天前
0.9.2022026/11/065 天前
0.9.2012026/11/056 天前

关于 @dbx-tools/shared-email-template 的常见问题

@dbx-tools/shared-email-template 是什么?

Universal React Email presentation shared by dbx-tools server and browser surfaces

如何安装 @dbx-tools/shared-email-template?

在项目目录运行 npm install @dbx-tools/shared-email-template,或使用 pnpm add / yarn add / bun add。

@dbx-tools/shared-email-template 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dbx-tools/shared-email-template 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dbx-tools/shared-email-template 可以商用吗?

@dbx-tools/shared-email-template 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dbx-tools/shared-email-template 的下载量有多少?

根据 npm 官方下载统计,@dbx-tools/shared-email-template 在 2026/10/12 – 2026/11/10 这 30 天内被下载 9,667 次,日均约 322 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dbx-tools/shared-email-template 还在维护吗?

最新版本 0.9.206 发布于 2026/11/11(今天);至今共发布 267 个版本,其中过去 12 个月发布了 267 个;首次发布于 2026/08/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。