Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.
/ elysia-websocket Public archive

Plugin for Elysia that add support for websocket

License

Notifications You must be signed in to change notification settings

elysiajs/elysia-websocket

Repository files navigation

WebSocket plugin is integrated to main Elysia package via elysia/ws since Elysia 0.3.0.

@elysiajs/websocket

Plugin for elysia that add support for websocket.

Installation

bun add @elysiajs/websocket

Example

import { Elysia } from 'elysia'
import { websocket } from '@elysiajs/websocket'

const app = new Elysia()
    .use(websocket())
    .ws('/ws', {
        message(ws, message) {
            ws.message('Hi')
        }
    })
    .listen(8080)

API

This plugin extends Elysia class with ws method.

ws

Register Websocket to route

Parameters:

ws(
    path: string,
    options: Partial<WebSocketHandler<Context>> & {
        schema?: Schema
        beforeHandle?: WithArray<HookHandler>
        headers?:
            | HeadersInit
            | (Context) => HeadersInt
    }
): this

About

Plugin for Elysia that add support for websocket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published