@frigear-nu/notify

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

Email, SMS and generic notification dispatch (pluggable drivers) Nuxt module, shared across Frigear modules.

原始使用文档
文档目录5 节
  1. Quick Setup
  2. Configuration
  3. Usage
  4. Server-side dispatch
  5. Built-in email drivers: resend , ses , cloudflare

@frigear-nu/notify

Generic notification driver/dispatch Nuxt module. Lets feature modules (e.g. @frigear-nu/users) dispatch email/SMS/simple notifications without ever deciding how they're delivered - that choice (and configuration) belongs to the app/consuming layer.

Quick Setup

Other modules declare @frigear-nu/notify as a moduleDependency, so it's installed automatically wherever they're used - you don't need to add it to modules yourself unless you want to configure it.

Configuration

Configure the module via the notify key in nuxt.config.ts. Every notification type (email, sms, simple) defaults to the built-in log driver (logs instead of sending):

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',
    },
  },
})

Only the configured driver for each notification type is ever resolved/loaded.

In-app toasts are not part of this module: call useToast() from Nuxt UI directly.

Example Custom Driver

// 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

Usage

Server-side dispatch

dispatchEmailNotification, dispatchSMSNotification, and dispatchSimpleNotification are auto-imported server-side wherever this module is installed:

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.`,
})

Built-in email drivers: resend, ses, cloudflare

Zero dependencies and zero config beyond environment variables - each driver talks to its provider with plain fetch (SES requests are signed with AWS SigV4 via Web Crypto). The driver and its credentials are read at runtime, so you can switch providers per environment without rebuilding:

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=...

Setting notify.email.driver in nuxt.config.ts to one of these names only changes the default; the env var still wins. A missing credential fails the send with an error naming the variable to set. Any other driver value is still treated as a path to a custom 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 是什么?

Email, SMS and generic notification dispatch (pluggable drivers) Nuxt module, shared across Frigear modules.

如何安装 @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 和提交记录判断。