Quickstart

From nothing to a notification on your screen in under a minute.

1. Get your keys

No account required. The CLI mints a project with two keys: a publishable key for the browser and a secret key for your server.

terminal
$ npx notify-dev init

✓ notify project created
  Publishable key:  ntfy_pk_...   (safe in the browser)
  Secret key:       ntfy_sk_...   (server-side only)

2. Add the script

Drop this into your page with your publishable key. It exposes a global notify.

index.htmlfrontend
<script src="https://api.getnotify.dev/notify.js?token=YOUR_PUBLISHABLE_KEY"></script>

3. Host the service worker

Browsers require the service worker to be same-origin with your page, so add a one-line file at your site root — /notify-sw.js:

notify-sw.jsfrontend
importScripts("https://api.getnotify.dev/sw.js");

4. Subscribe a user

Call this after the user opts in. It asks permission and registers the device.

app.jsfrontend
await notify.subscribe(currentUser.id)

5. Send from your backend

One request, using your secret key. Keep it in a server-side environment variable — never ship it to the browser.

server.jsbackend
await fetch("https://api.getnotify.dev/send", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    token: process.env.NOTIFY_SECRET_KEY,
    userId: user.id,
    title: "Acme",
    body: "Your export is ready!",
  }),
})
That’s the whole loop. If the notification didn’t appear, check that notifications are allowed for the site and that /notify-sw.js is reachable at your root.