{"id":23628265,"url":"https://github.com/nikhiladiga/react-wsx","last_synced_at":"2026-05-01T00:31:51.397Z","repository":{"id":57347863,"uuid":"382115431","full_name":"Nikhiladiga/react-wsx","owner":"Nikhiladiga","description":"A simple react websocket component written in typescript","archived":false,"fork":false,"pushed_at":"2021-07-01T18:27:59.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-28T02:13:45.960Z","etag":null,"topics":["react","typescript","websocket"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-wsx","language":"TypeScript","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/Nikhiladiga.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":"2021-07-01T17:55:18.000Z","updated_at":"2021-07-03T11:55:13.000Z","dependencies_parsed_at":"2022-08-28T03:01:44.097Z","dependency_job_id":null,"html_url":"https://github.com/Nikhiladiga/react-wsx","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/Nikhiladiga%2Freact-wsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikhiladiga%2Freact-wsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikhiladiga%2Freact-wsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikhiladiga%2Freact-wsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nikhiladiga","download_url":"https://codeload.github.com/Nikhiladiga/react-wsx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239540206,"owners_count":19655953,"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","typescript","websocket"],"created_at":"2024-12-28T00:32:30.571Z","updated_at":"2025-11-07T22:30:17.951Z","avatar_url":"https://github.com/Nikhiladiga.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-wsx\n## A simple react websocket component.\n\n[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)\n\nreact-wsx is a simple react websocket component which makes communicating with a websocket server very easy.\n\n### Installation\n```\nnpm install react-wsx\n```\n\n### Props\n#### url:*string* - *required*\nWebsocket server URL.\n\n#### onMessage:*Function* - *required*\nFunction to handle messages received from socket.\n\n#### onConnect:*Function* \nFunction to perform additional tasks on socket connection.\n\n#### onDisconnect:*Function* \nFunction to perform additional tasks on socket disconnect.\n\n#### onError:*Function* \nFunction to handle socket error\n\n#### debug:*Boolean*\nProp to enable/disable all data,events from socket printing in console. Default value is **true**.\n\n#### reconnect:*Boolean*\nProp to enable/disable reconnect socket feature. Default value is **true**.\n\n#### reconnectInterval:*number*\nProp to specify interval for trying to reconnect socket (in **milliseconds**).\n\n#### reconnectAttempts:*number*\nProp to specify the number of times socket connection should be attempted.\n\n# Usage\n```ts\nimport React, { Component } from 'react'\nimport ReactWS from 'react-wsx'\n\nexport default class App extends Component {\n\n    private socketRef = React.createRef\u003cany\u003e();\n\n    handleMessage = (message: any) =\u003e {\n        console.log(message);\n    }\n\n    handleConnect = () =\u003e {\n        console.log(\"connected\");\n        this.socketRef.current.sendMessage(\"Hello from the other side!\");\n    }\n\n    handleDisconnect = () =\u003e {\n        console.log(\"disconnected\");\n    }\n\n    handleError = () =\u003e {\n        console.log(\"error occurred\");\n    }\n\n\n    render() {\n        return (\n            \u003cdiv\u003e\n                \u003cReactWS\n                    url=\"ws://localhost:4000/ws\"\n                    debug\n                    onConnect={this.handleConnect}\n                    onDisconnect={this.handleDisconnect}\n                    reconnectAttempts={3}\n                    reconnectInterval={2000}\n                    onError={this.handleError}\n                    onMessage={this.handleMessage}\n                    reconnect\n                    ref={this.socketRef}\n                /\u003e\n            \u003c/div\u003e\n        )\n    }\n}\n```\n\n## License\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikhiladiga%2Freact-wsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikhiladiga%2Freact-wsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikhiladiga%2Freact-wsx/lists"}