{"id":30314297,"url":"https://github.com/socketio/bun-engine","last_synced_at":"2025-08-25T19:14:55.835Z","repository":{"id":310174686,"uuid":"1038965032","full_name":"socketio/bun-engine","owner":"socketio","description":"The Socket.IO low-level engine for Bun","archived":false,"fork":false,"pushed_at":"2025-08-25T06:35:01.000Z","size":30,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T09:22:41.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/socketio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-16T07:19:49.000Z","updated_at":"2025-08-25T08:12:35.000Z","dependencies_parsed_at":"2025-08-16T09:34:45.877Z","dependency_job_id":null,"html_url":"https://github.com/socketio/bun-engine","commit_stats":null,"previous_names":["socketio/bun-engine"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/socketio/bun-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fbun-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fbun-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fbun-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fbun-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socketio","download_url":"https://codeload.github.com/socketio/bun-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketio%2Fbun-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272075439,"owners_count":24869044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-17T19:00:36.281Z","updated_at":"2025-08-25T19:14:55.829Z","avatar_url":"https://github.com/socketio.png","language":"TypeScript","readme":"# @socket.io/bun-engine\n\nA highly efficient, Bun-powered engine for Socket.IO, designed to enhance real-time communication performance.\n\nThis package provides a custom engine for Socket.IO that leverages the speed and scalability of Bun to handle WebSocket\nconnections seamlessly.\n\nReference: https://socket.io/\n\n**Table of contents**\n\n\u003c!-- TOC --\u003e\n  * [How to use](#how-to-use)\n    * [With Bun's HTTP server](#with-buns-http-server)\n    * [With Hono](#with-hono)\n  * [Options](#options)\n    * [`path`](#path)\n    * [`pingTimeout`](#pingtimeout)\n    * [`pingInterval`](#pinginterval)\n    * [`upgradeTimeout`](#upgradetimeout)\n    * [`maxHttpBufferSize`](#maxhttpbuffersize)\n    * [`allowRequest`](#allowrequest)\n    * [`cors`](#cors)\n    * [`editHandshakeHeaders`](#edithandshakeheaders)\n    * [`editResponseHeaders`](#editresponseheaders)\n  * [License](#license)\n\u003c!-- TOC --\u003e\n\n## How to use\n\n### With Bun's HTTP server\n\n```js\nimport { Server as Engine } from \"@socket.io/bun-engine\";\nimport { Server } from \"socket.io\";\n\nconst io = new Server();\n\nconst engine = new Engine({\n  path: \"/socket.io/\",\n});\n\nio.bind(engine);\n\nio.on(\"connection\", (socket) =\u003e {\n  // ...\n});\n\nexport default {\n  port: 3000,\n  idleTimeout: 30, // must be greater than the \"pingInterval\" option of the engine, which defaults to 25 seconds\n\n  ...engine.handler(),\n};\n```\n\n### With Hono\n\n```js\nimport { Server as Engine } from \"@socket.io/bun-engine\";\nimport { Server } from \"socket.io\";\nimport { Hono } from \"hono\";\n\nconst io = new Server();\n\nconst engine = new Engine();\n\nio.bind(engine);\n\nio.on(\"connection\", (socket) =\u003e {\n  // ...\n});\n\nconst app = new Hono();\n\nconst { websocket } = engine.handler();\n\nexport default {\n  port: 3000,\n  idleTimeout: 30, // must be greater than the \"pingInterval\" option of the engine, which defaults to 25 seconds\n\n  fetch(req, server) {\n    const url = new URL(req.url);\n\n    if (url.pathname === \"/socket.io/\") {\n      return engine.handleRequest(req, server);\n    } else {\n      return app.fetch(req, server);\n    }\n  },\n\n  websocket\n}\n```\n\nReference: https://hono.dev/docs/\n\n## Options\n\n### `path`\n\nDefault value: `/engine.io/`\n\nIt is the name of the path that is captured on the server side.\n\nCaution! The server and the client values must match (unless you are using a\npath-rewriting proxy in between).\n\nExample:\n\n```ts\nconst engine = new Server(httpServer, {\n  path: \"/my-custom-path/\",\n});\n```\n\n### `pingTimeout`\n\nDefault value: `20000`\n\nThis value is used in the heartbeat mechanism, which periodically checks if the\nconnection is still alive between the server and the client.\n\nThe server sends a ping, and if the client does not answer with a pong within\n`pingTimeout` ms, the server considers that the connection is closed.\n\nSimilarly, if the client does not receive a ping from the server within\n`pingInterval + pingTimeout` ms, the client also considers that the connection\nis closed.\n\n### `pingInterval`\n\nDefault value: `25000`\n\nSee [`pingTimeout`](#pingtimeout) for more explanation.\n\n### `upgradeTimeout`\n\nDefault value: `10000`\n\nThis is the delay in milliseconds before an uncompleted transport upgrade is\ncancelled.\n\n### `maxHttpBufferSize`\n\nDefault value: `1e6` (1 MB)\n\nThis defines how many bytes a single message can be, before closing the socket.\nYou may increase or decrease this value depending on your needs.\n\n### `allowRequest`\n\nDefault value: `-`\n\nA function that receives a given handshake or upgrade request as its first\nparameter, and can decide whether to continue or not.\n\nExample:\n\n```ts\nconst engine = new Server({\n  allowRequest: (req, connInfo) =\u003e {\n    return Promise.reject(\"thou shall not pass\");\n  },\n});\n```\n\n### `cors`\n\nDefault value: `-`\n\nA set of options related to\n[Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)\n(CORS).\n\nExample:\n\n```ts\nconst engine = new Server({\n  cors: {\n    origin: [\"https://example.com\"],\n    allowedHeaders: [\"my-header\"],\n    credentials: true,\n  },\n});\n```\n\n### `editHandshakeHeaders`\n\nDefault value: `-`\n\nA function that allows to edit the response headers of the handshake request.\n\nExample:\n\n```ts\nconst engine = new Server({\n  editHandshakeHeaders: (responseHeaders, req, connInfo) =\u003e {\n    responseHeaders.set(\"set-cookie\", \"sid=1234\");\n  },\n});\n```\n\n### `editResponseHeaders`\n\nDefault value: `-`\n\nA function that allows to edit the response headers of all requests.\n\nExample:\n\n```ts\nconst engine = new Server({\n  editResponseHeaders: (responseHeaders, req, connInfo) =\u003e {\n    responseHeaders.set(\"my-header\", \"abcd\");\n  },\n});\n```\n\n## License\n\n[MIT](/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketio%2Fbun-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketio%2Fbun-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketio%2Fbun-engine/lists"}