{"id":13450868,"url":"https://github.com/iamgyz/use-socket.io-client","last_synced_at":"2025-07-27T02:33:11.545Z","repository":{"id":57170799,"uuid":"169726297","full_name":"iamgyz/use-socket.io-client","owner":"iamgyz","description":"https://www.npmjs.com/package/use-socket.io-client","archived":false,"fork":false,"pushed_at":"2020-04-03T09:40:24.000Z","size":6,"stargazers_count":50,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-24T21:04:59.403Z","etag":null,"topics":["react","react-hooks","reactjs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamgyz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-08T11:39:36.000Z","updated_at":"2023-10-16T22:24:07.000Z","dependencies_parsed_at":"2022-08-27T13:11:44.511Z","dependency_job_id":null,"html_url":"https://github.com/iamgyz/use-socket.io-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgyz%2Fuse-socket.io-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgyz%2Fuse-socket.io-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgyz%2Fuse-socket.io-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgyz%2Fuse-socket.io-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamgyz","download_url":"https://codeload.github.com/iamgyz/use-socket.io-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227751225,"owners_count":17814310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","react-hooks","reactjs"],"created_at":"2024-07-31T07:00:39.565Z","updated_at":"2024-12-02T15:22:24.453Z","avatar_url":"https://github.com/iamgyz.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# use-socket.io-client \r\n[![Build Status](https://travis-ci.org/iamgyz/use-socket.io-client.svg?branch=master)](https://travis-ci.org/iamgyz/use-socket.io-client)\r\n\r\nReact(^16.8.0) hook for socket.io-client, manipulate socket.io client without any side effect.\r\n\r\n```javascript\r\n//In legacy, you would write like this:\r\nimport io from 'socket.io-client';\r\nsocket = io('ws://host:port');\r\n\r\n//Now, you could easily write this inside the body of a function component:\r\nimport useSocket from 'use-socket.io-client';\r\nconst [socket] = useSocket('ws://host:port')\r\n```\r\n\r\n## Installation\r\n\r\n```\r\n$ npm i use-socket.io-client\r\n```\r\n\r\n## Example\r\n```javascript\r\nimport useSocket from 'use-socket.io-client';\r\n\r\n//You can treat \"useSocket\" as \"io\"\r\nconst [socket] = useSocket('ws://localhost:8080',{\r\n    autoConnect: false,\r\n    //any other options\r\n  });\r\n  \r\n//connect socket\r\nsocket.connect();\r\n\r\n//add event\r\nsocket.on('message',(text)=\u003e{\r\n  console.log(text);\r\n});\r\n\r\n//emit\r\nsocket.emit('message','this is demo..');\r\n```\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamgyz%2Fuse-socket.io-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamgyz%2Fuse-socket.io-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamgyz%2Fuse-socket.io-client/lists"}