Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with JavaScript frameworks #19

Open
darienmiller88 opened this issue Dec 10, 2023 · 1 comment
Open

Compatibility with JavaScript frameworks #19

darienmiller88 opened this issue Dec 10, 2023 · 1 comment

Comments

@darienmiller88
Copy link

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.

@ASoldo
Copy link

ASoldo commented Dec 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants