alepha@docs:~/docs/reference/primitives$
cat $notification.md1 min read
#$notification
#Import
typescript
1import { $notification } from "alepha/api/notifications";
#Overview
Creates a notification primitive for managing email/SMS notification templates.
Provides type-safe, reusable notification templates with multi-language support, variable substitution, and categorization for different notification channels.
#Options
| Option | Type | Required | Description |
|---|---|---|---|
name |
string |
No | |
description |
string |
No | |
category |
string |
No | |
critical |
boolean |
No | |
sensitive |
boolean |
No | |
translations |
Object |
No | |
schema |
T |
Yes |
#Examples
ts
1class NotificationTemplates { 2 welcomeEmail = $notification({ 3 name: "welcome-email", 4 category: "onboarding", 5 schema: t.object({ username: t.text(), activationLink: t.text() }), 6 email: { 7 subject: "Welcome to our platform!", 8 body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}` 9 }10 });11 12 async sendWelcome(user: User) {13 await this.welcomeEmail.push({14 variables: { username: user.name, activationLink: generateLink() },15 contact: user.email16 });17 }18}