{"id":20405466,"url":"https://github.com/iagormoraes/react-native-socket-io-wrapper","last_synced_at":"2025-07-31T02:12:59.598Z","repository":{"id":57340268,"uuid":"356964830","full_name":"iagormoraes/react-native-socket-io-wrapper","owner":"iagormoraes","description":"A native implementation of Socket.io for React Native.","archived":false,"fork":false,"pushed_at":"2021-12-27T19:39:15.000Z","size":499,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T12:42:58.053Z","etag":null,"topics":["android","react-native","socket-io"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iagormoraes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-11T19:50:38.000Z","updated_at":"2024-04-04T05:15:26.000Z","dependencies_parsed_at":"2022-09-07T10:22:18.924Z","dependency_job_id":null,"html_url":"https://github.com/iagormoraes/react-native-socket-io-wrapper","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagormoraes%2Freact-native-socket-io-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagormoraes%2Freact-native-socket-io-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagormoraes%2Freact-native-socket-io-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagormoraes%2Freact-native-socket-io-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iagormoraes","download_url":"https://codeload.github.com/iagormoraes/react-native-socket-io-wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586238,"owners_count":21128995,"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":["android","react-native","socket-io"],"created_at":"2024-11-15T05:11:02.013Z","updated_at":"2025-04-12T14:53:49.486Z","avatar_url":"https://github.com/iagormoraes.png","language":"TypeScript","readme":"react-native-socket-io-wrapper\n======================\n\nA native implementation of Socket.io for React Native.\n\n⚠️ Currently working only on Android, the future commits will focus on iOS.\n\n⚠️ Android uses `io.socket:socket.io-client:1.0.1` which supports `2.x (or 3.1.x / 4.x with allowEIO3: true)` as described at the [compatibility page](https://socketio.github.io/socket.io-client-java/installation.html).\n\n# Motivation\n\nAfter experiencing some performance problems with the JS socket.io library in React Native context, I decided to write a module using the Java solution that can be used in the UI/background threads and by doing so, keeping the JS thread more open to others expensive works and having the performance 💯, and a more stable development experience.\n\n# Table of contents\n\n- [Installation](#installation)\n  - [Adding with TurboReactPackage class](#adding-with-turboReactPackage-class)\n- [Usage](#usage)\n- [Methods](#methods)\n- [Todos](#todos)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\n```sh\nnpm install react-native-socket-io-wrapper\n```\n\n### Adding with TurboReactPackage class\n\nIn MainApplication.java add the following:\n```\n        @Override\n        protected List\u003cReactPackage\u003e getPackages() {\n          return Arrays.asList(\n            new SocketIoTurboPackage(), // \u003c-- add\n            new MainReactPackage()\n          );\n        }\n```\n\n\n## Usage\n\n```js\nimport SocketIO from \"react-native-socket-io-wrapper\";\n\n// ...\nconst socketIO = new SocketIO('http://127.0.0.1:3000', {\n  transports: ['websocket'],\n  query: SocketIO.serializeQuery({\n    token: 'Bearer JWT',\n  }),\n});\n```\n⚠️ For more info, please see in example of Android the usage of the socket with Hooks and lifecycle.\n\n## Methods\n\n### connect\n```js\nsocketIO.connect();\n```\nOpen socket connection.\n\n### disconnect\n```js\nsocketIO.disconnect();\n```\nClose socket connection.\n\n### on\n```js\nsocketIO.on(eventName, callback);\n```\nListen to socket event.\n\n### once\n```js\nsocketIO.once(eventName, callback);\n```\nListen once to socket event.\n\n#### Props\n\n``eventName: string``\n``callback: Function``\n\n### emit\n```js\nsocketIO.emit(eventName, data);\n```\nSend socket event.\n\n### off\n```js\nsocketIO.off(eventName, data);\n```\nRemove socket event listener.\n\n#### Props\n\n``eventName: string``\n``data: any``\n\n### connected\n```js\nsocketIO.connected(callback);\n```\nGet connection status of socket.\n\n### connectedSync\n```js\nsocketIO.connectedSync();\n```\nGet connection status of socket.\n\n⚠️ this method are synchronous blocking UI, use it carefully.\n\n### getId\n```js\nsocketIO.getId(callback);\n```\nGet id of socket.\n\n### getIdSync\n```js\nsocketIO.getIdSync();\n```\nGet id of socket.\n\n⚠️ this method are synchronous blocking UI, use it carefully.\n\n### updateSocketOptions\n```js\nsocketIO.updateSocketOptions(updatedOptions);\n```\nUpdate socket options, this updates general instances paths.\n\n### updateSocketOptionsSync\n```js\nsocketIO.updateSocketOptionsSync(updatedOptions);\n```\nUpdate socket options, this updates general instances paths.\n\n⚠️ this method are synchronous blocking UI, use it carefully.\n\n## Todos\n\n- Write tests\n- Implement iOS native module\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiagormoraes%2Freact-native-socket-io-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiagormoraes%2Freact-native-socket-io-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiagormoraes%2Freact-native-socket-io-wrapper/lists"}