Skip to content

Commit 1af6ab3

Browse files
docs: add example with Elysia
Related: elysiajs/elysia#1358
1 parent 079c273 commit 1af6ab3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Reference: https://socket.io/
1313
* [How to use](#how-to-use)
1414
* [With Bun's HTTP server](#with-buns-http-server)
1515
* [With Hono](#with-hono)
16+
* [With Elysia](#with-elysia)
1617
* [Options](#options)
1718
* [`path`](#path)
1819
* [`pingTimeout`](#pingtimeout)
@@ -93,6 +94,34 @@ export default {
9394

9495
Reference: https://hono.dev/docs/
9596

97+
### With Elysia
98+
99+
Requires [`elysia@>=1.3.21`](https://github.com/elysiajs/elysia/pull/1358).
100+
101+
```js
102+
import { Server as Engine } from "@socket.io/bun-engine";
103+
import { Server } from "socket.io";
104+
import { Elysia } from "elysia";
105+
106+
const io = new Server();
107+
const engine = new Engine();
108+
109+
io.bind(engine);
110+
111+
io.on("connection", (socket) => {
112+
// ...
113+
});
114+
115+
const app = new Elysia()
116+
.all('/socket.io/', ({ request, server }) => engine.handleRequest(request, server))
117+
.listen({
118+
port: 3000,
119+
...engine.handler(),
120+
});
121+
```
122+
123+
Reference: https://elysiajs.com/at-glance.html
124+
96125
## Options
97126

98127
### `path`

0 commit comments

Comments
 (0)