{"_id":"@armaanjain/courier-web-sdk","name":"@armaanjain/courier-web-sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@armaanjain/courier-web-sdk","version":"0.1.1","description":"Robust MQTT Web SDK with automatic reconnection, subscription recovery, heartbeat monitoring, and optional React bindings.","author":{"name":"Gojek"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/gojek/courier-web.git"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js","require":"./dist/react.cjs"}},"scripts":{"build":"tsup","dev":"tsup --watch","lint":"eslint src --ext .ts,.tsx","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"dependencies":{"mqtt":"^5.1.4","rxjs":"^7.8.1"},"devDependencies":{"@types/node":"^20.10.0","@types/react":"^18.2.0","tsup":"^8.0.0","typescript":"^5.3.0"},"peerDependencies":{"react":">=18.0.0"},"peerDependenciesMeta":{"react":{"optional":true}},"publishConfig":{"access":"public"},"_id":"@armaanjain/courier-web-sdk@0.1.1","gitHead":"dd1c794fe0cecbdeeceea637abc3c6523b7a7975","bugs":{"url":"https://github.com/gojek/courier-web/issues"},"homepage":"https://github.com/gojek/courier-web#readme","_nodeVersion":"20.19.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-dsoKS0Ze13P7V4UENNNZv3rzfs1TTIuPwN+QnxPScfcJC7FMj/py/lOYejDo1nsQP8KR68kfN9AetvfbjZOB/Q==","shasum":"a42e33c7873fd020e3c4f6f80858472ce81b3a10","tarball":"https://registry.npmjs.org/@armaanjain/courier-web-sdk/-/courier-web-sdk-0.1.1.tgz","fileCount":18,"unpackedSize":358193,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD2Q6d8b8wAFu4VoTyegVi9Xxe21y7JzND+Unf9fWs58wIhALhTutnVZgI9QiFtsL7mREiCkF+XHWIU9O1oSkL0sVkW"}]},"_npmUser":{"name":"armaanjain","email":"armaan.jain@gojek.com"},"directories":{},"maintainers":[{"name":"armaanjain","email":"armaan.jain@gojek.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/courier-web-sdk_0.1.1_1777884941751_0.135845069245075"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-04T08:55:41.700Z","0.1.1":"2026-05-04T08:55:41.925Z","modified":"2026-05-04T08:55:42.105Z"},"maintainers":[{"name":"armaanjain","email":"armaan.jain@gojek.com"}],"description":"Robust MQTT Web SDK with automatic reconnection, subscription recovery, heartbeat monitoring, and optional React bindings.","homepage":"https://github.com/gojek/courier-web#readme","repository":{"type":"git","url":"git+https://github.com/gojek/courier-web.git"},"author":{"name":"Gojek"},"bugs":{"url":"https://github.com/gojek/courier-web/issues"},"license":"MIT","readme":"<a href=\"https://github.com/gojek/courier-web/actions\">\n\t<img alt=\"Build Status\" src=\"https://github.com/gojek/courier-web/actions/workflows/build.yml/badge.svg\" />\n</a>\n<a href=\"https://gojek.github.io/courier-web/\">\n\t<img alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" />\n</a>\n<a href=\"https://github.com/gojek/courier-web/graphs/commit-activity\">\n\t<img alt=\"Maintenance\" src=\"https://img.shields.io/badge/maintained-yes-green.svg\" />\n</a>\n<a href=\"https://github.com/gojek/courier-web/releases/latest\">\n\t<img alt=\"GitHub Release Date\" src=\"https://img.shields.io/github/release-date/gojek/courier-web\" />\n</a>\n<a href=\"https://github.com/gojek/courier-web/commits/main\">\n\t<img alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/gojek/courier-web\" />\n</a>\n\n[![Discord : Gojek Courier](https://img.shields.io/badge/Discord-Gojek%20Courier-blue.svg)](https://discord.gg/C823qK4AK7)\n\n## About Courier Web\n\nCourier Web is a TypeScript SDK for creating robust, long-running connections using the MQTT protocol in web applications.\n\nLong running connection is a persistent connection established between client & server for instant bi-directional communication. A long running connection is maintained for maximum possible duration with the help of keep alive packets.\n\nMQTT is an extremely lightweight protocol which works on publish/subscribe messaging model. It is designed for connections with remote locations where a \"small code footprint\" is required or the network bandwidth is limited.\n\nThe protocol usually runs over TCP/IP via WebSockets in the browser; however, any network protocol that provides ordered, lossless, bi-directional connections can support MQTT.\n\nMQTT has 3 built-in QoS levels for Reliable Message Delivery:\n\n* **QoS 0 (At most once)** - the message is sent only once and the client and broker take no additional steps to acknowledge delivery (fire and forget).\n\n* **QoS 1 (At least once)** - the message is re-tried by the sender multiple times until acknowledgement is received (acknowledged delivery).\n\n* **QoS 2 (Exactly once)** - the sender and receiver engage in a two-level handshake to ensure only one copy of the message is received (assured delivery).\n\n## Detailed Documentation\n\nFind the detailed documentation here - https://gojek.github.io/courier-web/\n\nEnd-to-end courier example - https://gojek.github.io/courier/docs/Introduction\n\n## Features\n\n* Clean, simple API with callback and RxJS Observable support\n\n* Automatic Reconnection with subscription restoration\n\n* Heartbeat Monitoring with stale connection detection\n\n* Subscription Ledger with periodic broker-side audit\n\n* Exponential Backoff retry for auth and connection failures\n\n* Credential Persistence via cookie-based storage\n\n* Framework-agnostic core with optional React bindings\n\n* Full TypeScript support with comprehensive type definitions\n\n## Getting Started\n\n### Installation\n\n```bash\nnpm install @gojek/courier-web-sdk\n```\n\n### Quick Start\n\n```ts\nimport { RealtimeClient } from \"@gojek/courier-web-sdk\";\n\nconst client = new RealtimeClient({\n  endpoint: {\n    host: \"broker.example.com\",\n    port: 443,\n    scheme: \"wss\",\n    path: \"/mqtt\",\n    clientId: \"my-client-123\",\n    username: \"user\",\n    password: \"token\",\n  },\n  topicAudit: { enabled: true, intervalMs: 10_000 },\n});\n\nawait client.connect();\nawait client.subscribe(\"chat/room/42\");\n\nclient.onEnvelope(\"chat/room/42\", (topic, data) => {\n  console.log(\"Received:\", data);\n});\n\nawait client.publish(\"chat/room/42\", { text: \"Hello!\" });\n```\n\n### React Usage\n\n```tsx\nimport { RealtimeClient } from \"@gojek/courier-web-sdk\";\nimport {\n  RealtimeScope,\n  useLinkStatus,\n  useInbox,\n  useTopicBind,\n} from \"@gojek/courier-web-sdk/react\";\n\nconst client = new RealtimeClient({ endpoint: { ... } });\nawait client.connect();\n\nfunction App() {\n  return (\n    <RealtimeScope client={client}>\n      <ChatRoom channelId=\"42\" />\n    </RealtimeScope>\n  );\n}\n\nfunction ChatRoom({ channelId }: { channelId: string }) {\n  const { isLive, heartbeatOk } = useLinkStatus();\n  const { bound } = useTopicBind(`chat/room/${channelId}`);\n\n  useInbox(`chat/room/${channelId}`, (topic, data) => {\n    console.log(\"New message:\", data);\n  });\n\n  if (!isLive) return <div>Connecting...</div>;\n  if (!bound) return <div>Subscribing...</div>;\n  return <div>Live! Heartbeat: {heartbeatOk ? \"OK\" : \"Degraded\"}</div>;\n}\n```\n\n## Contribution Guidelines\n\nRead our [contribution guide](./CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to the Courier Web SDK.\n\n## License\n\nCourier Web is [MIT Licensed](./LICENSE).\n","readmeFilename":"README.md","_rev":"1-2ac4cd509ffc0fe1142ca66eff11a45f"}