Schedule reminders that arrive as browser push notifications — even when the tab is closed. Demonstrates how the Agents SDK's persistent state and scheduling combine naturally with the Web Push API.
- The client registers a service worker and subscribes to push notifications
- The agent stores the push subscription in its state and schedules reminders using
this.schedule() - When an alarm fires, the agent sends a push notification via the
web-pushlibrary — no open tab required - The service worker receives the push event and displays a native notification
Generate VAPID keys (writes them to .env automatically):
npm run generate-vapid-keysThen edit .env to set your VAPID_SUBJECT if needed.
Install and run:
npm install
npm run startthis.schedule(delaySeconds, callback, payload)— fires reminders at the right time, even after restartsthis.state/this.setState()— persists push subscriptions and reminder list across hibernation@callable— exposes agent methods to the client over WebSocketthis.broadcast()— notifies connected clients in real time when a reminder fires