The Poki Networking Library is a peer-to-peer library for web games, using WebRTC datachannels to provide UDP connections between players directly. Like the Steam Networking Library, but for web.
Netlib tries to make WebRTC as simple to use as the WebSocket interface (for game development).
This library is still under heavy development and considered in alpha. The library API can and will change without warning and without bumping the major version. Make sure to get in touch if you want to go live with this netlib.
One missing feature that is next on the roadmap is lobby listing and discovery. Currently you can only connect peers by having players share a lobby code externally.
First add @poki/netlib
as a dependency to your project:
# either using yarn:
yarn add @poki/netlib
# or using npm:
npm i @poki/netlib
Then you can import and create a Network interface:
import { Network } from '@poki/netlib'
const network = new Network('<your-game-id-here>')
(any random UUID is a valid game-id, but if your game is hosted at Poki you should use Poki's game-id)
Next up: read the basic usage guide and make sure to checkout the example code.
The netlib is a peer-to-peer networking library which means players are connected directly to each other and data send between them is never send to a server.
That said, to setup these connections we need a signaling service. This backend and STUN/TURN servers are hosted by Poki for free. You can however always decide to host the backend yourself.