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

Svelte(Kit) websocket example #4

Open
karimfromjordan opened this issue Feb 20, 2023 · 2 comments
Open

Svelte(Kit) websocket example #4

karimfromjordan opened this issue Feb 20, 2023 · 2 comments

Comments

@karimfromjordan
Copy link
Contributor

Similar to #3. and a very frequently asked question on Discord. I'm not sure however if this example should use plain websockets or the socket.io library. And to make this example self contained we probably have to use the Vite development server to setup the websocket server and mention that you need a separate websocket server in production.

For the actual content, would a simple chat app to demonstrate the bidirectional nature of websockets be too much for an example? Also, this example could use either plain Svelte or SvelteKit. I think the most important part to show here would be how to manage a websocket connection with a custom store. And if it's a chat app the store could just be extended with a store.send_message() function.

@dummdidumm
Copy link
Member

Regarding the use case, I think a very simple chat app is perfect for this. Regarding "self-contained" - I would be ok with having a backend folder at the root in this example where a super simple node express/whatever project is set up.

@karimfromjordan
Copy link
Contributor Author

Ok great. And I think using SvelteKit instead of plain Svelte would actually be better because one problem/question that often comes up is how to initialize a websocket connection in a SSR enabled SvelteKit app.

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