Giter VIP home page Giter VIP logo

sveltekit-sse-chat-example's Introduction

sveltekit-sse-chat-example

Really simple example chat webapp built with SvelteKit and sveltekit-sse.

It's a playground to try out Server Sent Events ("SSE") with Publish–subscribe pattern ("pubsub") on the practical use case of a chat application.

Warning

This is a technical prototype! There is no security, no authentication, no authorization and no checking. This can easily be misused by bad actors. Don't use this in production!

Running the project

Checkout the git repository, install dependencies (npm i) and run on localhost (npm run dev) or listen on all local IPs (npm run dev -- --host).

Architecture

Single page SvelteKit webapp using a single +page.svelte with variables name and room.

Using components EnterName, SelectRoom and Chat. Supporting event emitter files /api/rooms/+server.js and /api/chat/+server.js using sveltekit-sse.

Small libraries for in-memory storage (/lib/server/chats.js) and pubsub (lib/servers/pubsub.js).

Component EnterName returns the entered name to the main page via bind.

EnterName screenshot

Component SelectRoom returns the selected or entered room to the main page via bind, it uses the rooms SSE to list existing rooms, updating in real time.

SelectRoom screenshot

Then component Chat will be rendered with parameters name and room. It uses chat SSE with query parameter name and room. This provides multiple events, namely users with the full list of user names of the current room and message which contains the newly POSTed messages.

Chat screenshot

sveltekit-sse-chat-example's People

Contributors

bluepuma77 avatar razshare avatar

Stargazers

Vitor Hugo avatar Anatoliy avatar Verious Smith III avatar Cali (Renato Caliari) avatar Florian Schmid avatar Stanislav Khromov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.