{"id":13484997,"url":"https://github.com/tinyhttp/tinyws","last_synced_at":"2026-02-01T10:01:39.214Z","repository":{"id":38268268,"uuid":"366096250","full_name":"tinyhttp/tinyws","owner":"tinyhttp","description":"🚡 tiny WebSocket middleware for Node.js","archived":false,"fork":false,"pushed_at":"2024-06-26T15:32:52.000Z","size":328,"stargazers_count":409,"open_issues_count":1,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-07T00:46:44.687Z","etag":null,"topics":["express","http","javascript","nodejs","polka","server","tinyhttp","websocket","ws"],"latest_commit_sha":null,"homepage":"https://npm.im/tinyws","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/tinyhttp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"ko_fi":"v1rtl","liberapay":"v1rtl","issuehunt":"talentlessguy","github":["talentlessguy"]}},"created_at":"2021-05-10T15:48:25.000Z","updated_at":"2025-08-27T13:21:14.000Z","dependencies_parsed_at":"2024-06-18T13:54:04.204Z","dependency_job_id":"cb9a5cbb-0b7c-4672-aeef-d9c32e4babde","html_url":"https://github.com/tinyhttp/tinyws","commit_stats":null,"previous_names":["talentlessguy/tinyws"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tinyhttp/tinyws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyhttp","download_url":"https://codeload.github.com/tinyhttp/tinyws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28975278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T09:57:52.632Z","status":"ssl_error","status_checked_at":"2026-02-01T09:57:49.143Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["express","http","javascript","nodejs","polka","server","tinyhttp","websocket","ws"],"created_at":"2024-07-31T17:01:42.055Z","updated_at":"2026-02-01T10:01:39.206Z","avatar_url":"https://github.com/tinyhttp.png","language":"TypeScript","funding_links":["https://ko-fi.com/v1rtl","https://liberapay.com/v1rtl","https://issuehunt.io/r/talentlessguy","https://github.com/sponsors/talentlessguy"],"categories":["TypeScript","T","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/tinyhttp/tinyws/master/logo.svg\" alt=\"tinyws\"\u003e\n\u003cp\u003e\u003csub\u003e🚡 tiny WebSocket middleware for Node.js\u003c/sub\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n[![Version][v-badge-url]][npm-url] [![Downloads][dl-badge-url]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Codecov][cov-badge-url]][cov-url]\n\n\u003c/div\u003e\n\n_**tinyws**_ is a WebSocket middleware for Node.js based on [ws](https://github.com/websockets/ws), inspired by [koa-easy-ws](https://github.com/b3nsn0w/koa-easy-ws).\n\nCheck the [chat example](examples/chat) out to get familiar with tinyws.\n\n## Features\n\n- Small size (**498B**)\n- Easy to use (only `req.ws` and nothing else)\n- Framework-agnostic (works with tinyhttp, express etc)\n- Written in TypeScript\n- Pure ESM\n\n## Why not [express-ws](https://github.com/HenningM/express-ws)?\n\nbecause express-ws is...\n\n- [Abandoned](https://github.com/HenningM/express-ws/issues/135) since 2018 💀\n- Doesn't come with types out of the box (have to install `@types/express-ws`)\n- Not compatible with tinyhttp and polka\n- Buggy as hell\n- Doesn't have tests\n\n## Install\n\n```sh\npnpm i ws tinyws\n```\n\n## Example\n\n```ts\nimport { App, Request } from '@tinyhttp/app'\nimport { tinyws, TinyWSRequest } from 'tinyws'\n\nconst app = new App\u003cRequest \u0026 TinyWSRequest\u003e()\n\napp.use('/ws', async (req, res) =\u003e {\n  if (req.ws) {\n    const ws = await req.ws()\n\n    return ws.send('hello there')\n  } else {\n    res.send('Hello from HTTP!')\n  }\n})\n\nconst server = app.listen(3000)\ntinyws(app, server)\n```\n\n### Restricting WebSocket to specific paths\n\nYou can restrict WebSocket handling to specific paths using the `paths` option:\n\n```ts\n// Single path\ntinyws(app, server, { paths: '/ws' })\n\n// Multiple paths\ntinyws(app, server, { paths: ['/ws', '/socket'] })\n```\n\nSee [examples](examples) for express and polka integration.\n\n[v-badge-url]: https://img.shields.io/npm/v/tinyws.svg?style=for-the-badge\u0026color=F55A5A\u0026label=\u0026logo=npm\n[npm-url]: https://www.npmjs.com/package/tinyws\n[cov-badge-url]: https://img.shields.io/coveralls/github/tinyhttp/tinyws?style=for-the-badge\u0026color=F55A5A\n[cov-url]: https://coveralls.io/github/tinyhttp/tinyws\n[dl-badge-url]: https://img.shields.io/npm/dt/tinyws?style=for-the-badge\u0026color=F55A5A\n[github-actions]: https://github.com/tinyhttp/tinyws/actions\n[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/tinyws/main.yml?branch=master\u0026style=for-the-badge\u0026color=F55A5A\u0026label=\u0026logo=github\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Ftinyws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinyhttp%2Ftinyws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Ftinyws/lists"}