Back to gallery
Push notifications
Subscribe the browser and send a Web Push message.
Dev-limited
registerPush({ visitorId }) + push.send({ visitorId }) Runs on the deployed app. The browser side works everywhere, but the dev
server's platform client has no
push, so sending only works on the deployed
kitchensink. There, VAPID keys, the service worker and encryption are all handled by the
platform. For scheduling and receipts, see the push showcase card.1 · Subscribe this browser
Calls registerPush() behind your click — it prompts for
permission and registers the service worker.
permission: default
push on dev-server: available
// browser — behind a user gesture. Registers the platform's service worker,
// asks for permission and stores the subscription against a visitor id.
import { registerPush } from '@maravilla-labs/platform/push';
const { subscriptionId } = await registerPush({ visitorId, topics: ['demo'] });
// +page.server.ts — target that visitor (or a userId / topic)
import { push } from '$lib/platform.server';
const report = await push.send({ visitorId }, { title, body }); // → SendReport
// later, idempotent by key: re-scheduling replaces the pending job
await push.schedule({ visitorId }, { title, body }, {
at: new Date(Date.now() + 60_000),
key: `demo:${visitorId}`
}); ts