@frigear-nu/notify

中文文档
0.2.5发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 4461

电子邮件、短信和通用通知发送(可插驱动程序) Nuxt模块,在Frigear模块中共享.

中文使用文档
文档目录5 节
  1. 快速设置
  2. 配置
  3. 使用量
  4. 服务器端发送
  5. 内建的电子邮件驱动 : resend , (中文(简体) ), ses , (中文(简体) ), cloudflare

@frigear-nu/通知

一般通知驱动/发送 Nuxt 模块 。 让功能模块(例如:. @frigear-nu/users(中文(简体) ) 发送电子邮件/短信/简便通知,而从未决定其状况 交付 - 该选择(和配置)属于应用/消耗层.

快速设置

其他模块声明 @frigear-nu/notify 作为 moduleDependency,所以安装了 无论在哪里使用,你都不必加入 modules 除非你们 想要配置它.

配置

通过 notify 键入 nuxt.config.ts。每一种通知类型(email, (中文(简体) ), sms, (中文(简体) ), simple) 内置默认值 log 驱动程序( 日志而不是发送) :

export default defineNuxtConfig({
  notify: {
    email: {
      // Name of a built-in driver (`'log'`, the default - logs instead of sending) or a path to
      // a function (default export) matching the `EmailDriver` signature, for a real provider
      // (Resend, SMTP, ...).
      driver: '~/server/utils/resend-email-driver',
    },
    sms: {
      // Same idea, matching the `SMSDriver` signature, for a real provider (Twilio, ...).
      driver: '~/server/utils/twilio-sms-driver',
    },
    simple: {
      // Same idea, matching the `SimpleDriver` signature, for generic push notifications.
      driver: 'log',
    },
  },
})

只有每个通知类型的已配置驱动程序才能解析/装入 .

苹果土司不属于这个模块:呼叫 useToast() 直接从 Nuxt UI.

示例自定义驱动程序

// server/utils/resend-email-driver.ts
import type { EmailDriver } from '@frigear-nu/notify/types'

const sendWithResend: EmailDriver = async (notification) => {
  // ... call your provider's API with notification.to/subject/body/text
}

export default sendWithResend

使用量

服务器端发送

dispatchEmailNotification, (中文(简体) ), dispatchSMSNotification,以及 dispatchSimpleNotification 为: 安装此模块的自动导入服务器侧 :

await dispatchEmailNotification({
  to: user.email,
  subject: 'Welcome!',
  body: '<p>Thanks for signing up.</p>',
  text: 'Thanks for signing up.',
})

await dispatchSMSNotification({
  to: user.phone,
  body: 'Your verification code is 123456.',
})

await dispatchSimpleNotification({
  title: 'New signup',
  text: `${user.email} just signed up.`,
})

内建的电子邮件驱动 : resend, (中文(简体) ), ses, (中文(简体) ), cloudflare

环境变量以外的零依赖性和零配置 - 每个驱动程序用平面向提供者说话 fetch (SES请求通过Web Crypto与AWS SigV4签署). 驾驶员及其证书在 运行时间这样 可以不重建每个环境而切换提供者 :

NUXT_NOTIFY_EMAIL_DRIVER=resend   # log (default) | resend | ses | cloudflare
NUXT_NOTIFY_EMAIL_FROM="Frigear <[email protected]>"

# resend
NUXT_NOTIFY_EMAIL_RESEND_API_TOKEN=...

# ses (v2 API)
NUXT_NOTIFY_EMAIL_SES_REGION=eu-west-1
NUXT_NOTIFY_EMAIL_SES_ACCESS_KEY_ID=...
NUXT_NOTIFY_EMAIL_SES_SECRET_ACCESS_KEY=...
NUXT_NOTIFY_EMAIL_SES_SESSION_TOKEN=...   # optional, for temporary credentials

# cloudflare (Email Service)
NUXT_NOTIFY_EMAIL_CLOUDFLARE_ACCOUNT_ID=...
NUXT_NOTIFY_EMAIL_CLOUDFLARE_API_TOKEN=...

设置 notify.email.driver 内 nuxt.config.ts 改为其中之一 赢了 缺少证书的发送失败, 并错误指定要设置的变量 。 任何其他 driver 值不变 作为通向习惯的途径 EmailDriver。 。 。 .

版本与发布记录

@frigear-nu/notify 共发布 21 个版本,首次发布于 2026/10/09;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.5latest2026/11/123 天前
0.2.42026/11/0411 天前
0.2.32026/11/0411 天前
0.2.22026/11/0312 天前
0.2.12026/11/0312 天前
0.2.02026/11/0114 天前

关于 @frigear-nu/notify 的常见问题

@frigear-nu/notify 是什么?

电子邮件、短信和通用通知发送(可插驱动程序) Nuxt模块,在Frigear模块中共享.

如何安装 @frigear-nu/notify?

在项目目录运行 npm install @frigear-nu/notify,或使用 pnpm add / yarn add / bun add。

@frigear-nu/notify 支持 TypeScript 吗?

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

@frigear-nu/notify 支持 ESM 还是 CommonJS?

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

@frigear-nu/notify 可以商用吗?

@frigear-nu/notify 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@frigear-nu/notify 的下载量有多少?

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

@frigear-nu/notify 还在维护吗?

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