{"id":20276178,"url":"https://github.com/vanilla-icecream/fastify-uws","last_synced_at":"2025-10-25T13:03:28.812Z","repository":{"id":184401240,"uuid":"671829551","full_name":"Vanilla-IceCream/fastify-uws","owner":"Vanilla-IceCream","description":"A performant HTTP and WebSocket server for Fastify with uWebSockets.","archived":false,"fork":false,"pushed_at":"2024-11-13T06:22:12.000Z","size":938,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T21:02:52.319Z","etag":null,"topics":["fastify","uwebsockets","uws"],"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/Vanilla-IceCream.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-07-28T08:27:41.000Z","updated_at":"2025-02-05T00:37:06.000Z","dependencies_parsed_at":"2024-02-25T08:29:25.530Z","dependency_job_id":"87e02669-8f06-43d4-b1ab-28fd503c93dd","html_url":"https://github.com/Vanilla-IceCream/fastify-uws","commit_stats":null,"previous_names":["vanilla-icecream/fastify-uws"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanilla-IceCream%2Ffastify-uws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanilla-IceCream%2Ffastify-uws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanilla-IceCream%2Ffastify-uws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanilla-IceCream%2Ffastify-uws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vanilla-IceCream","download_url":"https://codeload.github.com/Vanilla-IceCream/fastify-uws/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351426,"owners_count":21089269,"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","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":["fastify","uwebsockets","uws"],"created_at":"2024-11-14T13:12:46.630Z","updated_at":"2025-10-25T13:03:23.789Z","avatar_url":"https://github.com/Vanilla-IceCream.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![fastify-uws](./.github/assets/logo.png)\n\n# fastify-uws\n\nA performant HTTP and WebSocket server for Fastify with [uWebSockets](https://github.com/uNetworking/uWebSockets.js).\n\n## Installation\n\nInstall `fastify-uws` with your favorite package manager:\n\n```sh\n$ npm i fastify-uws\n# or\n$ yarn add fastify-uws\n# or\n$ pnpm i fastify-uws\n# or\n$ bun add fastify-uws\n```\n\n## Supported\n\n- `fastify` v5.x\n- `@fastify/websocket` v11.x\n\n## Usage\n\nJust two lines are needed to speed up your Fastify application.\n\n```ts\n// app.ts\nimport fastify from 'fastify';\nimport { serverFactory } from 'fastify-uws'; // Import here\n\nimport router from '~/plugins/router';\n\nexport default () =\u003e {\n  const app = fastify({\n    logger: {\n      transport: {\n        target: '@fastify/one-line-logger',\n      },\n    },\n    serverFactory, // And use here\n  });\n\n  app.register(router);\n\n  return app;\n};\n```\n\n```ts\n// server.ts\nimport app from './app';\n\nconst server = app();\n\nconst start = async () =\u003e {\n  try {\n    await server.listen({\n      host: '127.0.0.1',\n      port: 3000,\n    });\n  } catch (err) {\n    server.log.error(err);\n    process.exit(1);\n  }\n};\n\nstart();\n```\n\n### Use [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)\n\n```ts\n// src/routes/hello-http/+handler.ts\nimport type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';\nimport { Type } from '@sinclair/typebox';\n\nexport default (async (app) =\u003e {\n  app.get(\n    '',\n    {\n      schema: {\n        response: {\n          200: Type.Object({\n            message: Type.String(),\n          }),\n        },\n      },\n    },\n    async (req, reply) =\u003e {\n      return reply.send({\n        message: 'Hello, World!',\n      });\n    },\n  );\n}) as FastifyPluginAsyncTypebox;\n```\n\n#### With [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n\n```ts\n// app.ts\nimport multipart from '@fastify/multipart';\n\napp.register(multipart);\n```\n\n```ts\n// src/routes/hello-fd/+handler.ts\nimport type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';\nimport fs from 'node:fs';\nimport { pipeline } from 'node:stream/promises';\n\nexport default (async (app) =\u003e {\n  app.post('', async (req, reply) =\u003e {\n    const data = await req.file();\n\n    data.file; // stream\n    data.fields; // other parsed parts\n    data.fieldname;\n    data.filename;\n    data.encoding;\n    data.mimetype;\n\n    await pipeline(data.file, fs.createWriteStream(data.filename));\n    // or\n    // await data.toBuffer(); // Buffer\n\n    return reply.send({ message: 'ok' });\n  });\n}) as FastifyPluginAsyncTypebox;\n```\n\n### Use [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)\n\nJust a single line of change can speed up your WebSocket application in Fastify.\n\n```diff\n- import websocket from '@fastify/websocket';\n+ import { websocket } from 'fastify-uws';\n```\n\n```ts\n// app.ts\nimport { websocket } from 'fastify-uws';\n\napp.register(websocket);\n```\n\n```ts\n// src/routes/hello-ws/+handler.ts\nimport type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';\n\nexport default (async (app) =\u003e {\n  app.get('', { websocket: true }, (socket, request) =\u003e {\n    app.log.info('Client connected');\n\n    socket.on('message', (message: MessageEvent) =\u003e {\n      console.log(`Client message: ${message}`);\n      socket.send('Hello from Fastify!');\n    });\n\n    socket.on('close', () =\u003e {\n      app.log.info('Client disconnected');\n    });\n  });\n}) as FastifyPluginAsyncTypebox;\n```\n\n### Use [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)\n\n```ts\n// app.ts\nimport { eventsource } from 'fastify-uws';\n\napp.register(eventsource);\n```\n\n```ts\n// src/routes/hello-sse/+handler.ts\nimport type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';\n\nexport default (async (app) =\u003e {\n  app.get('', (req, reply) =\u003e {\n    let index = 0;\n\n    reply.sse({ id: String(index), data: `Some message ${index}` });\n\n    const interval = setInterval(() =\u003e {\n      index += 1;\n\n      reply.sse({ id: String(index), data: `Some message ${index}` });\n\n      if (index === 10) {\n        clearInterval(interval);\n      }\n    }, 1000);\n\n    req.raw.on('close', () =\u003e {\n      clearInterval(interval);\n      app.log.info('Client disconnected');\n      reply.sse({ event: 'close' });\n    });\n  });\n}) as FastifyPluginAsyncTypebox;\n```\n\n## Benchmarks\n\n### [oha v1.4.5](https://github.com/hatoo/oha)\n\n```sh\n$ oha -c 500 -z 10s --no-tui http://0.0.0.0:3000/api/hello-world\n```\n\n|               |       Version | Language        | Router | Requests/sec |\n| :------------ | ------------: | :-------------- | -----: | -----------: |\n| hyper         |         1.4.1 | Rust            |      ✗ |  56,175.6102 |\n| warp          |         0.3.7 | Rust            |      ✓ |  55,868.5861 |\n| axum          |         0.7.7 | Rust            |      ✓ |  54,588.2828 |\n| bun           |        1.1.30 | TypeScript/Bun  |      ✗ |  54,098.4841 |\n| graphul       |         1.0.1 | Rust            |      ✓ |  53,949.4400 |\n| poem          |         3.1.0 | Rust            |      ✓ |  53,849.0781 |\n| uws           |       20.48.0 | JavaScript/Node |      ✗ |  52,802.8029 |\n| elysia        |        1.1.17 | TypeScript/Bun  |      ✓ |  52,257.3305 |\n|               |               |                 |        |     ~ 5.5k ~ |\n| hyper-express |        6.17.2 | JavaScript/Node |      ✓ |  46,745.4887 |\n| hono          |         4.6.3 | TypeScript/Bun  |      ✓ |  46,685.6014 |\n| nhttp         |         2.0.2 | TypeScript/Deno |      ✓ |  44,874.2535 |\n| deno          |         2.0.0 | TypeScript/Deno |      ✗ |  44,753.8552 |\n| hono          |         4.6.3 | TypeScript/Deno |      ✓ |  43,280.7544 |\n|               |               |                 |        |     ~ 9.2k ~ |\n| h3            |        1.12.0 | TypeScript/Bun  |      ✓ |  34,043.4693 |\n| fastify-uws   |         1.0.0 | JavaScript/Node |      ✓ |  31,295.8715 |\n| polka         | 1.0.0-next.28 | JavaScript/Node |      ✓ |  31,086.5543 |\n| oak           |        17.0.0 | TypeScript/Deno |      ✓ |  30,730.7971 |\n| node          |       20.18.0 | JavaScript/Node |      ✗ |  29,230.1719 |\n| oak           |        17.0.0 | TypeScript/Bun  |      ✓ |  27,449.3417 |\n| fastify       |         5.0.0 | JavaScript/Node |      ✓ |  27,408.6679 |\n| hono          |         4.6.3 | JavaScript/Node |      ✓ |  25,138.5659 |\n|               |               |                 |        |     ~ 4.9k ~ |\n| h3            |        1.12.0 | JavaScript/Node |      ✓ |  20,193.2311 |\n|               |               |                 |        |     ~ 9.2k ~ |\n| express       |        4.21.0 | JavaScript/Node |      ✓ |  10,949.1532 |\n\n## Credits\n\nThis project is based on [`@geut/fastify-uws`](https://github.com/geut/fastify-uws) and is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanilla-icecream%2Ffastify-uws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanilla-icecream%2Ffastify-uws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanilla-icecream%2Ffastify-uws/lists"}