{"_id":"@ahmadster/usews","_rev":"1-3ee153b36e3e12fe3e96cf411feb5f0f","name":"@ahmadster/usews","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ahmadster/usews","version":"1.0.0","description":"React Hooks Websocket Hook","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ahmadster/useWS.git"},"keywords":["react","hooks","websocket","ws"],"author":{"name":"Ahmad Baitalmal","email":"ahmad@baitalmal.com"},"license":"MIT","bugs":{"url":"https://github.com/ahmadster/useWS/issues"},"homepage":"https://github.com/ahmadster/useWS#readme","dependencies":{"react":"^16.12.0","react-dom":"^16.12.0"},"gitHead":"ce12bccd5bd1103899ed3d5c539ee59f7389a759","_id":"@ahmadster/usews@1.0.0","_nodeVersion":"13.2.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-84jgc13xdvDgCF9pTi03XOxI3ccWASMf+3nXQ0GtQHjK/bPguHrqI6TG5KyO6inAG2ri/+eKsLuyX7TAh+pbFg==","shasum":"b530547568aa1ad1a260bf011dc960c40bc0ef77","tarball":"https://registry.npmjs.org/@ahmadster/usews/-/usews-1.0.0.tgz","fileCount":4,"unpackedSize":5918,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeCTX5CRA9TVsSAnZWagAAUhUP/RcyZIoLBtELw3sxCMXt\nq+Do+llZ20XOLYUZrNK3ZKR5rh56gIuvK4wbmLRzpp57hNqYQGn8xY/hMVNu\nW+NyUqEIhy3IcU1BQkPuBSdb1ODtSqpKJUk+VNim2JvWDk1BucdnpzYYQS9i\n7wm7rEen7CO/8PdAA9Atgd0VO69pLqCGxLAgR785kz9cmFlxCgcufibUeC3y\npcipHd6FLf/NxnTQSPF4tqNl9xD2QScj9fGi/G2FsL3rfN2AIu/ia0z5pSBO\noIn1coGleEXdzwszRt/K6lJJGNh/1zNIMCiCCHC4meosJa4c3haFcPhm93Mc\nWL5PTP/Tlk167dZ+ryLFJt5b86yDNWogTRWfjjy68BkJDoLZBtwDH1hcbgyB\necKmOc9BLoNCojngACLO/wD8hL7XtpuLWmPRJ4xNAgVsW/0/p0wsScDyte0C\nYzfQc1sLwo8uzSFwyu31DuoTPkekUrjR99bS0GxM/jQnGUE5yuB4ozp8eY2y\nvipquwyUCnHmxMu3HObvMC2vg56rGoYv/0JJs+Gg3xwYkTCCFDAz6U1VQq/V\nmfhMojAs7oPeZ4+0JQCiWY7basYuxNS6C/DclFgh7uVtr6Cfyp1pkWWmPcIg\nBWd+YAIgeMXfzjyA2ZhkJQNRJZ4TgulwMoTnLgVjR8Ksa43nqA/NFsX1a5DD\nm5Uu\r\n=7IKU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID6/3M1TZXdos36yhtdTqN3APClh7CDx4pSLj/lpOn/zAiEA9sf5NeFZj95HuHkXYAl2mYaEWhtTvcMSMWLi6RuLVa4="}]},"maintainers":[{"name":"ahmadster","email":"ahmad@baitalmal.com"}],"_npmUser":{"name":"ahmadster","email":"ahmad@baitalmal.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/usews_1.0.0_1577661944235_0.8369819103254141"},"_hasShrinkwrap":false}},"time":{"created":"2019-12-29T23:25:44.196Z","1.0.0":"2019-12-29T23:25:44.348Z","modified":"2022-04-04T12:12:27.188Z"},"maintainers":[{"name":"ahmadster","email":"ahmad@baitalmal.com"}],"description":"React Hooks Websocket Hook","homepage":"https://github.com/ahmadster/useWS#readme","keywords":["react","hooks","websocket","ws"],"repository":{"type":"git","url":"git+https://github.com/ahmadster/useWS.git"},"author":{"name":"Ahmad Baitalmal","email":"ahmad@baitalmal.com"},"bugs":{"url":"https://github.com/ahmadster/useWS/issues"},"license":"MIT","readme":"# useWS - React Hooks Websocket\nThe easiest and most fuss-free Websocket implementation for React Hooks.\n\n## Quick Start\nAdd `useWS` to your project, npm or yarn:\n```bash\nyarn add useWS\n```\n\nSimplist example using the defaults \n```javascript\nimport React, {useReducer} from \"react\"\nimport {useWS} from \"./useWS\"\n\nexport default function App() {\n  // our simple message handler\n\n  const handleMessage = (msg) => console.log(`Got message`,msg)\n  // connect to the /ws endpoint on the same url by default passing our handler\n  const [ws, wsStatus] = useWS(handleMessage)\n\n  // send a message to the server\n  const sendData = () => {\n   \tws.sendJson({\"re\": `hello world`})\n  }\n\n  return <div className={`App`}>\n    The Websocket is {wsStatus}\n    <button onClick={()=>sendData()}>Say Hello</div>\n  </div>\n}\n\n```\n\n\n## Customizing\n\n```javascript\nimport {useWS} from \"./useWS\"\n\n// Optional overrides, defaults shown here\nlet wsOptions = {\n  wsURL: () => `${window.location.origin.replace(`http`, `ws`)}/ws`,\n  maxMissedHeartbeats: 3,\n  reconnectDelay: 20000,\n  pingDelay: 500,\n  pingPayload: {re: `ping`},\n  pongPayload: {re: `pong`},\n  debugMode: false,\n  onOpen: undefined,\n  onClose: undefined,\n  onMessage: undefined,\n  onError: undefined\n}\n//\n//\n//\nconst [ws, wsStatus] = useWS(handleMessage, wsOptions)\n```\n","readmeFilename":"README.md"}