{"id":42363902,"url":"https://github.com/poki/netlib","last_synced_at":"2026-01-27T17:53:51.881Z","repository":{"id":51646289,"uuid":"383424972","full_name":"poki/netlib","owner":"poki","description":"The Poki Networking Library for online multiplayer web games!","archived":false,"fork":false,"pushed_at":"2026-01-26T12:27:48.000Z","size":1640,"stargazers_count":66,"open_issues_count":11,"forks_count":63,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-01-27T01:52:53.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poki.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-06T10:12:26.000Z","updated_at":"2026-01-26T12:27:52.000Z","dependencies_parsed_at":"2024-04-12T09:27:53.877Z","dependency_job_id":"4be2fa65-3b9c-4ea8-b90f-71f6efa3e4d4","html_url":"https://github.com/poki/netlib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/poki/netlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poki%2Fnetlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poki%2Fnetlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poki%2Fnetlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poki%2Fnetlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poki","download_url":"https://codeload.github.com/poki/netlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poki%2Fnetlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28817613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: 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":[],"created_at":"2026-01-27T17:53:51.348Z","updated_at":"2026-01-27T17:53:51.871Z","avatar_url":"https://github.com/poki.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Poki Networking Library \u0026nbsp;\u0026nbsp;[\u003cimg src=\"https://img.shields.io/npm/v/@poki/netlib?color=lightgray\"\u003e](https://www.npmjs.com/package/@poki/netlib)\n\n\u003cimg align=\"right\" src=\"https://raw.githubusercontent.com/poki/netlib/main/.github/logo.png\" width=140\u003e\nThe Poki Networking Library is a peer-to-peer networking library for web games, leveraging WebRTC datachannels to enable direct UDP connections between players. Think of it as the Steam Networking Library for the web, designed to make WebRTC as simple to use as WebSockets for game development.\n\n\u003cp\u003e\u003c/p\u003e\n\n\u003e [!WARNING]\n\u003e This library is still under development and considered a beta. While it's being actively used in production by some games, the API can change. Make sure to get in touch if you want to go live with this so we can keep you up-to-date about changes.\n\n## Features\n\n- **True Peer-to-Peer (P2P) Networking**\n  - Direct client-to-client connections without a central game server\n  - Lower latency for geographically close players\n  - Reduced server costs and infrastructure complexity\n  - No need to duplicate game logic between client and server\n  - Three main advantages:\n    1. No server costs - there is no server running the game\n    2. No double implementation - you don't need to write your game logic twice (for the client and the server)\n    3. Lower latency - when players are living close by, the latency is often much lower than when connected via a server\n\n- **UDP Performance**\n  - Choice between reliable (TCP) and unreliable (UDP) channels\n  - Optimized for real-time gaming with minimal latency\n  - Perfect for fast-paced multiplayer games\n  - Unlike WebSockets or HTTP (which use TCP), UDP doesn't pause new packets when one packet is slow or dropped\n  - Includes reliable data channels for critical events like chat messages or NPC spawns\n\n- **Easy to Use**\n  - Simple WebSocket-like API\n  - Built-in lobby system with filtering\n  - Automatic connection management\n  - Comprehensive TypeScript support\n\n- **Production Ready**\n  - Fallback to TURN servers when direct P2P fails\n  - Built-in connection quality monitoring\n  - Automatic reconnection handling\n  - Secure by default\n\n## Quick Start\n\n1. Install the package:\n```sh\nyarn add @poki/netlib\n# or\nnpm install @poki/netlib\n```\n\n2. Create a network instance:\n```js\nimport { Network } from '@poki/netlib'\nconst network = new Network('\u003cyour-game-id\u003e')\n```\n\n3. Create or join a lobby:\n```js\n// Create a new lobby\nnetwork.on('ready', () =\u003e {\n  network.create()\n})\n\n// Or join an existing one\nnetwork.on('ready', () =\u003e {\n  network.join('ed84')\n})\n```\n\n4. Start communicating:\n```js\n// Send messages\nnetwork.broadcast('unreliable', { x: 100, y: 200 })\n\n// Receive messages\nnetwork.on('message', (peer, channel, data) =\u003e {\n  console.log(`Received from ${peer.id}:`, data)\n})\n```\n\nFor more detailed examples and API documentation:\n- [Basic Usage Guide](./docs/basic-usage.md)\n- [Example Usage](./example/)\n\n## Roadmap\n\n- [x] Basic P2P connectivity\n- [x] Lobby system\n- [x] Lobby discovery and filtering\n- [ ] WebRTC data compression\n- [ ] Connection statistics and debugging tools\n- [ ] More extensive documentation\n- [ ] API stability\n\n## Architecture\n\n### Network Stack\n```\nYour Game\n    ↓\nNetlib API\n    ↓\nWebRTC DataChannels\n    ↓\n(STUN/TURN if needed)\n    ↓\nUDP Transport\n```\n\n### Infrastructure Components\n\n#### 1. Signaling Server\n- Handles initial peer discovery\n- Manages lobby creation and joining\n- Facilitates WebRTC connection establishment\n\n#### 2. STUN/TURN Servers\n- STUN: Helps peers discover their public IP (by default Google STUN servers)\n- TURN: Provides fallback relay when direct P2P fails (when using the Poki hosted version, Cloudflare TURN servers are used)\n\n## Self-Hosting\n\nWhile Poki provides hosted STUN/TURN and signaling services for free, you can also self-host these components:\n\n1. Set up your own signaling server\n\n    Using the provided Docker image:\n    ```sh\n    $ docker build -t netlib .\n    $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 -e ENV=local netlib\n    ```\n    Or by running the signaling server binary directly:\n    ```sh\n    $ go build -o signaling cmd/signaling/main.go\n    $ ENV=local ./signaling\n    ```\n2. For persistent storage remove `ENV=local` and set `DATABASE_URL` to your PostgreSQL database URL.\n3. Configure your own STUN/TURN servers.\n4. Initialize the network with custom endpoints:\n```js\nconst network = new Network('\u003cgame-id\u003e', {\n  signalingServer: 'wss://your-server.com',\n  stunServer: 'stun:your-stun.com:3478',\n  turnServer: 'turn:your-turn.com:3478'\n})\n```\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./.github/CONTRIBUTING.md) for details. This project adheres to the [Poki Vulnerability Disclosure Policy](https://poki.com/en/c/vulnerability-disclosure-policy).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Main Contributors\n\n- [Koen Bollen](https://github.com/koenbollen)\n- [Erik Dubbelboer](https://github.com/erikdubbelboer)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoki%2Fnetlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoki%2Fnetlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoki%2Fnetlib/lists"}