• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
nbbaier

nbbaier

ntfy

A TypeScript library for sending notifications via ntfy.sh
Public
Like
1
ntfy
Home
Code
5
README.md
index.ts
ntfy.ts
test.ts
types.ts
Connections
Environment variables
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

ntfy

A TypeScript library for sending push notifications via ntfy.sh from Val Town.

Quick Start

import { Ntfy } from "https://esm.town/v/nbbaier/ntfy/index.ts"; // Simple message await Ntfy.publish("my-topic", "Hello from Val Town! πŸŽ‰"); // With options await Ntfy.publish("my-topic", { message: "Disk usage at 95%!", title: "Server Alert", priority: 5, tags: ["warning", "skull"], click: "https://example.com/dashboard", markdown: true, });

Features

  • Simple API β€” one-liner to send notifications
  • Full ntfy.sh support β€” title, priority, tags, actions, attachments, markdown, scheduled delivery, email forwarding
  • Auth support β€” token auth, basic auth, or env vars
  • Self-hosted support β€” works with any ntfy server
  • TypeScript β€” fully typed with exported interfaces

Usage

Static Methods (simplest)

For quick notifications to ntfy.sh with no auth:

import { Ntfy } from "https://esm.town/v/nbbaier/ntfy/index.ts"; await Ntfy.publish("my-topic", "Backup complete βœ…");

Instance (self-hosted / auth)

import { Ntfy } from "https://esm.town/v/nbbaier/ntfy/index.ts"; const ntfy = new Ntfy({ server: "https://ntfy.myserver.com", token: "tk_abc123", }); await ntfy.publish("alerts", { message: "Deployment finished", title: "CI/CD", priority: 4, tags: ["rocket"], });

Default Topic

Set a default topic to use notify() without specifying a topic each time:

const ntfy = new Ntfy({ defaultTopic: "my-alerts" }); await ntfy.notify("Something happened!"); // Or use the NTFY_TOPIC environment variable and the static method: await Ntfy.notify("Something happened!");

Action Buttons

await Ntfy.publish("my-topic", { message: "Garage door open for 15 min", actions: [ { action: "view", label: "Open Dashboard", url: "https://home.example.com" }, { action: "http", label: "Close Door", url: "https://api.example.com/close", method: "PUT" }, { action: "copy", label: "Copy Code", value: "abc123" }, ], });

Priority Names

import { Ntfy, PriorityName } from "https://esm.town/v/nbbaier/ntfy/index.ts"; await Ntfy.publish("my-topic", { message: "Critical alert!", priority: PriorityName.urgent, // 5 });

Environment Variables

The library automatically reads these env vars as defaults:

VariableDescription
NTFY_SERVERServer URL (default: https://ntfy.sh)
NTFY_TOKENAccess token for auth
NTFY_USERNAMEUsername for basic auth
NTFY_PASSWORDPassword for basic auth
NTFY_TOPICDefault topic for notify()

All Publish Options

interface PublishOptions { message?: string; // Notification body title?: string; // Notification title priority?: 1|2|3|4|5; // 1=min, 3=default, 5=urgent tags?: string[]; // Emoji shortcodes & tags click?: string; // URL opened on tap attach?: string; // Attachment URL filename?: string; // Attachment filename delay?: string; // Scheduled delivery email?: string; // Forward via email markdown?: boolean; // Enable markdown actions?: Action[]; // Action buttons icon?: string; // Notification icon URL }

Error Handling

import { Ntfy, NtfyError } from "https://esm.town/v/nbbaier/ntfy/index.ts"; try { await Ntfy.publish("my-topic", "test"); } catch (e) { if (e instanceof NtfyError) { console.error(e.statusCode, e.responseBody); } }

Architecture

Rendering mermaid diagram...
Code
README.mdindex.tsntfy.tstest.tstypes.ts
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
AboutAlternativesPricingBlogNewsletterCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2026 Val Town, Inc.