gosf icon indicating copy to clipboard operation
gosf copied to clipboard

Compatibility with JavaScript frameworks

Open darienmiller88 opened this issue 1 year ago • 1 comments

I was wondering if this socket.io library was compatible with JavaScript frameworks like React, Vue or Svelte, because JavaScript code written in an HTML file works perfectly fine, but applying the same code to a basic React or Svelte frontend doesn't yield the same results. The connection is made successfully, but messages are not coming through.

darienmiller88 avatar Dec 10 '23 21:12 darienmiller88

First, you need to use npm i socket.io in your blank Vue/React/Svelte since you are not using cdn links but the npm package. Socket.io is a basic websocket package with some convenient utility functions for creating rooms and lobbies. Next, you import in your main.ts this socket.io package and provide it to your app. From there, you have Vue/React/Svelte life cycle hooks you can use to send events and receive events.

ASoldo avatar Dec 10 '23 22:12 ASoldo