FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
n4k0m3
n4k0m3push
Remix of jrmann100/push
Public
Like
push
Home
Code
7
README.md
getVapidDetails.tsx
H
main.tsx
pushFrontend.js
pushSendNotification.tsx
subscription.tsx
tryPush.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
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
/
README.md
Code
/
README.md
Search
9/7/2025
README.md

🔔 push

Send push notifications from val.town to your device!

demo

Setup

  • 🔀 Remix this val
  • Open HTTP Endpoint (optionally set a custom subdomain)
  • Create an API key with Users: Read-only permission
  • Paste your API key into the password field
  • Subscribe and allow push notification permissions
  • You should receive a 👋 notification!

Usage

Calling push notifications in another val:

Create val
import { sendNotification } from "https://esm.town/v/YOUR_PUSH_REMIX_HERE/pushSendNotification.tsx"; console.log( await sendNotification("Example notification", { data: { url: "https://example.com" }, }), );

Sending a push notification from outside of Val Town using an API call:

Create val
fetch("https://YOUR_ENDPOINT_HERE/push", { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Bearer YOUR_API_TOKEN_HERE", }, body: JSON.stringify([ "Example notification", { data: { url: "https://example.com" } }, ]), });

Sending a push notification from outside of Val Town using cURL:

curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN_HERE" \ -d '["Example notification",{"data":{"url":"https://example.com"}}]' \ "https://YOUR_ENDPOINT_HERE/push"

Caveats

  • The service currently only supports sending notifications to one device at a time, but could be extended to work with multiple devices/users.
  • For instant configuration, the service stores (a) crypto keys used to encrypt notifications and (b) the device currently subscribed to notifications in blob storage. It is the user's responsibility to secure these blobs from being exposed by other vals.
Get started with a template:
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.