npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@poki/netlib

v0.0.18

Published

<img align="right" src="https://raw.githubusercontent.com/poki/netlib/main/.github/logo.png" width=140> The Poki Networking Library is a peer-to-peer networking library for web games, leveraging WebRTC datachannels to enable direct UDP connections between

Readme

The Poki Networking Library   

[!WARNING] 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.

Features

  • True Peer-to-Peer (P2P) Networking

    • Direct client-to-client connections without a central game server
    • Lower latency for geographically close players
    • Reduced server costs and infrastructure complexity
    • No need to duplicate game logic between client and server
    • Three main advantages:
      1. No server costs - there is no server running the game
      2. No double implementation - you don't need to write your game logic twice (for the client and the server)
      3. Lower latency - when players are living close by, the latency is often much lower than when connected via a server
  • UDP Performance

    • Choice between reliable (TCP) and unreliable (UDP) channels
    • Optimized for real-time gaming with minimal latency
    • Perfect for fast-paced multiplayer games
    • Unlike WebSockets or HTTP (which use TCP), UDP doesn't pause new packets when one packet is slow or dropped
    • Includes reliable data channels for critical events like chat messages or NPC spawns
  • Easy to Use

    • Simple WebSocket-like API
    • Built-in lobby system with filtering
    • Automatic connection management
    • Comprehensive TypeScript support
  • Production Ready

    • Fallback to TURN servers when direct P2P fails
    • Built-in connection quality monitoring
    • Automatic reconnection handling
    • Secure by default

Quick Start

  1. Install the package:
yarn add @poki/netlib
# or
npm install @poki/netlib
  1. Create a network instance:
import { Network } from '@poki/netlib'
const network = new Network('<your-game-id>')
  1. Create or join a lobby:
// Create a new lobby
network.on('ready', () => {
  network.create()
})

// Or join an existing one
network.on('ready', () => {
  network.join('ed84')
})
  1. Start communicating:
// Send messages
network.broadcast('unreliable', { x: 100, y: 200 })

// Receive messages
network.on('message', (peer, channel, data) => {
  console.log(`Received from ${peer.id}:`, data)
})

For more detailed examples and API documentation:

Roadmap

  • [x] Basic P2P connectivity
  • [x] Lobby system
  • [x] Lobby discovery and filtering
  • [ ] WebRTC data compression
  • [ ] Connection statistics and debugging tools
  • [ ] More extensive documentation
  • [ ] API stability

Architecture

Network Stack

Your Game
    ↓
Netlib API
    ↓
WebRTC DataChannels
    ↓
(STUN/TURN if needed)
    ↓
UDP Transport

Infrastructure Components

1. Signaling Server

  • Handles initial peer discovery
  • Manages lobby creation and joining
  • Facilitates WebRTC connection establishment

2. STUN/TURN Servers

  • STUN: Helps peers discover their public IP (by default Google STUN servers)
  • TURN: Provides fallback relay when direct P2P fails (when using the Poki hosted version, Cloudflare TURN servers are used)

Self-Hosting

While Poki provides hosted STUN/TURN and signaling services for free, you can also self-host these components:

  1. Set up your own signaling server

    Using the provided Docker image:

    $ docker build -t netlib .
    $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 -e ENV=local netlib

    Or by running the signaling server binary directly:

    $ go build -o signaling cmd/signaling/main.go
    $ ENV=local ./signaling
  2. For persistent storage remove ENV=local and set DATABASE_URL to your PostgreSQL database URL.

  3. Configure your own STUN/TURN servers.

  4. Initialize the network with custom endpoints:

const network = new Network('<game-id>', {
  signalingServer: 'wss://your-server.com',
  stunServer: 'stun:your-stun.com:3478',
  turnServer: 'turn:your-turn.com:3478'
})

Contributing

We welcome contributions! Please see our Contributing Guide for details. This project adheres to the Poki Vulnerability Disclosure Policy.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Main Contributors