{"_id":"@bilalhasson/push-relay-browser","_rev":"2-78660dac4065844bd17cdf118b5cab9c","name":"@bilalhasson/push-relay-browser","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.2":{"name":"@bilalhasson/push-relay-browser","version":"0.1.2","keywords":["web-push","notifications","push-relay","service-worker"],"_id":"@bilalhasson/push-relay-browser@0.1.2","maintainers":[{"name":"bilalhasson","email":"bilalnageeb@hotmail.co.uk"}],"homepage":"https://github.com/bilalhasson/push-relay#readme","bugs":{"url":"https://github.com/bilalhasson/push-relay/issues"},"dist":{"shasum":"22886cfcceb99f60d28c5b3c99baf79c332659de","tarball":"https://registry.npmjs.org/@bilalhasson/push-relay-browser/-/push-relay-browser-0.1.2.tgz","fileCount":10,"integrity":"sha512-5oNFoJwORwkhHpAh0MdKp7yQEpLdOWBryaOE1o9SjUKv5aWPghHswSUWBglCAKUOj7GqDMZC83Kbo2o4Ag+uIg==","signatures":[{"sig":"MEUCID9mL4AcpOMrQAnEiqknrhbQbptKW5fOy0D1MZIkg+TdAiEA1TlevB6HxAgpHV/3ohLaXhkWlOzLoQ80r56i2tKXk7E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15879},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./sw":{"types":"./dist/sw.d.ts","import":"./dist/sw.js"}},"gitHead":"7805f34f5f6f878bf85e45cc7e976a82abfd63d7","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepare":"npm run build","typecheck":"tsc --noEmit"},"_npmUser":{"name":"bilalhasson","email":"bilalnageeb@hotmail.co.uk"},"repository":{"url":"git+https://github.com/bilalhasson/push-relay.git","type":"git"},"_npmVersion":"11.6.2","description":"Browser subscribe client for Push Relay — Service Worker + permission + subscribe + register.","directories":{},"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/push-relay-browser_0.1.2_1783865336178_0.543433692943069","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@bilalhasson/push-relay-browser","version":"0.1.3","description":"Browser subscribe client for Push Relay — Service Worker + permission + subscribe + register.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/bilalhasson/push-relay.git"},"publishConfig":{"access":"public"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./sw":{"types":"./dist/sw.d.ts","import":"./dist/sw.js"}},"keywords":["web-push","notifications","push-relay","service-worker"],"scripts":{"build":"tsc -p tsconfig.json","prepare":"npm run build","typecheck":"tsc --noEmit","test":"vitest run"},"devDependencies":{"typescript":"^5.6.3","vitest":"^2.1.8"},"gitHead":"756a71b5fdee7624a400d23fe8d35d980c718f23","_id":"@bilalhasson/push-relay-browser@0.1.3","bugs":{"url":"https://github.com/bilalhasson/push-relay/issues"},"homepage":"https://github.com/bilalhasson/push-relay#readme","_nodeVersion":"20.19.5","_npmVersion":"11.6.2","dist":{"integrity":"sha512-/d6K3rG9hnA0Y8V5pAHWhRMWwPjtOhzMG+cYQHCMuGj6/zRpWv3EdzI7rrc+kfr/LLOoDO8LP8kgRbWaUac3KQ==","shasum":"8c4b069b914f7b4314c34ce9ed42edc8b819b121","tarball":"https://registry.npmjs.org/@bilalhasson/push-relay-browser/-/push-relay-browser-0.1.3.tgz","fileCount":11,"unpackedSize":16968,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFopzG/cHUVMcI5nmnH0g6MvcpmGLiSD0MtCqLl9RimlAiEAzIak68uZ2L9jDIB4tzCIV5wdeuR6fmbY4/+pgX5Hhp0="}]},"_npmUser":{"name":"bilalhasson","email":"bilalnageeb@hotmail.co.uk"},"directories":{},"maintainers":[{"name":"bilalhasson","email":"bilalnageeb@hotmail.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/push-relay-browser_0.1.3_1783867409097_0.05534049389217599"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-12T14:08:56.009Z","modified":"2026-07-12T14:43:29.330Z","0.1.2":"2026-07-12T14:08:56.320Z","0.1.3":"2026-07-12T14:43:29.240Z"},"bugs":{"url":"https://github.com/bilalhasson/push-relay/issues"},"homepage":"https://github.com/bilalhasson/push-relay#readme","keywords":["web-push","notifications","push-relay","service-worker"],"repository":{"type":"git","url":"git+https://github.com/bilalhasson/push-relay.git"},"description":"Browser subscribe client for Push Relay — Service Worker + permission + subscribe + register.","maintainers":[{"name":"bilalhasson","email":"bilalnageeb@hotmail.co.uk"}],"readme":"# @bilalhasson/push-relay-browser\n\nThe browser half of [Push Relay](https://push-relay.demo.bilalhasson.com): subscribe a browser to\nWeb Push (Service Worker → permission → `pushManager.subscribe`) and register the subscription — a\nfew lines from any React / Vue / vanilla PWA. Zero dependencies.\n\n- Interactive API reference: **https://push-relay.demo.bilalhasson.com/docs**\n- Source & issues: **https://github.com/bilalhasson/push-relay** (`clients/browser`)\n- Backend send SDK: [`@bilalhasson/push-relay`](https://github.com/bilalhasson/push-relay/tree/main/clients/node) (Node) · `push-relay` (Python, via pip)\n\n## Install\n\n```bash\nnpm install @bilalhasson/push-relay-browser\n```\n\n## Two integration modes\n\n**A — browser-direct (turnkey).** Register straight to Push Relay with your app's **publishable\nkey** (`ppk_…`). Requires your origin to be allow-listed on the app (CORS). No backend needed for\nthe subscribe half.\n\n```ts\nimport { PushRelayClient } from \"@bilalhasson/push-relay-browser\";\n\nconst client = new PushRelayClient({\n  baseUrl: \"https://push-relay.demo.bilalhasson.com\",\n  publishableKey: \"ppk_…\",\n  serviceWorkerUrl: \"/sw.js\",\n});\n\nawait client.subscribe(\"user-123\"); // SW register → permission → subscribe → register\nawait client.unsubscribe();\nawait client.isSubscribed();\n```\n\n**B — backend-proxied.** The client posts the subscription to *your* endpoint, which relays it to\nPush Relay server-side (no CORS, no publishable key in the browser):\n\n```ts\nconst client = new PushRelayClient({\n  baseUrl: \"https://push-relay.demo.bilalhasson.com\",\n  registerUrl: \"/api/push/subscribe\", // your backend forwards it to Push Relay\n});\nawait client.subscribe(\"user-123\");\n```\n\n**Sending** is always done from your backend with the **secret** key (`psk_…`) — via\n[`@bilalhasson/push-relay`](https://github.com/bilalhasson/push-relay/tree/main/clients/node) (Node)\nor the Python `push-relay` SDK. Never put a secret key in the browser.\n\n## Your Service Worker\n\nWeb Push needs a Service Worker **served same-origin at your app's root**. Import the handler into\nyour (bundled) SW:\n\n```ts\n// sw.ts (bundled by your app, served at /sw.js)\nimport { pushRelayListen } from \"@bilalhasson/push-relay-browser/sw\";\npushRelayListen(self);\n```\n\nNot bundling your SW? Copy the `push` / `notificationclick` handler from Push Relay's `static/sw.js`\ninto a plain `sw.js` at your root.\n\n## API\n\n| | |\n| --- | --- |\n| `new PushRelayClient(opts)` | `{ baseUrl, publishableKey? \\| registerUrl?, vapidPublicKey?, serviceWorkerUrl = \"/sw.js\", serviceWorkerScope?, fetch? }` |\n| `client.subscribe(label)` | register SW → permission → subscribe → register → `Promise<PushSubscriptionJSON>` |\n| `client.unsubscribe()` | unsubscribe locally (+ tell Push Relay in mode A) |\n| `client.isSubscribed()` / `client.isSupported()` | `Promise<boolean>` / `boolean` |\n| `import \"@bilalhasson/push-relay-browser/sw\"` | `pushRelayListen(self)` — SW push + notificationclick handlers |\n","readmeFilename":"README.md","license":"MIT"}