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

@acapans/lavalink-client

v1.0.3

Published

Production-grade Lavalink v4 client with multi-node support, session resuming, and penalty-based load balancing

Readme

Lavalink Client v4

Production-grade Lavalink v4 client library for Node.js with multi-node support, session resuming, penalty-based load balancing, and circuit breakers.

Features

  • REST-first Architecture - Built for Lavalink v4's REST API protocol
  • Multi-Node Load Balancing - Penalty-based node selection with configurable weights
  • WebSocket Resilience - Exponential backoff with jitter for reconnection
  • Session Resuming - Zero-downtime client restarts
  • Circuit Breakers - Automatic fault isolation
  • Queue Persistence - Redis and in-memory store support
  • Auto-skip & Auto-resume - Intelligent playback handling
  • Player Migration - Automatic failover on node disconnect
  • Full TypeScript - Complete type safety

Installation

npm install lavalink-client

Quick Start

import { Manager, RedisQueueStore } from 'lavalink-client';

const manager = new Manager({
  nodes: [
    {
      id: 'node-1',
      host: 'localhost',
      port: 2333,
      authorization: 'youshallnotpass',
      retries: 10,
      reconnectInterval: 5000,
    },
  ],
  userId: 'YOUR_DISCORD_USER_ID',
  sendGatewayPayload: (guildId, payload) => {
    // Forward to Discord gateway
    guild.shard.send(payload);
  },
  queueStore: new RedisQueueStore({ host: 'localhost', port: 6379 }),
  autoSkip: true,
  autoResume: true,
});

manager.on('nodeConnect', (node) => {
  console.log(`Node ${node.id} connected`);
});

manager.on('trackStart', (player, track) => {
  console.log(`Playing: ${track.info.title}`);
});

manager.connect();

Configuration Options

Node Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | id | string | required | Unique node identifier | | host | string | required | Lavalink server hostname | | port | number | required | Lavalink server port | | authorization | string | required | Lavalink password | | secure | boolean | false | Use WSS/HTTPS | | regions | string[] | [] | Voice regions for routing | | retries | number | 10 | Max reconnection attempts | | reconnectInterval | number | 5000 | Base reconnection delay (ms) | | resumeTimeout | number | 30000 | Session resume timeout (ms) | | moveOnDisconnect | boolean | true | Auto-migrate players on disconnect |

Manager Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | nodes | NodeOptions[] | required | Lavalink node configurations | | userId | string | required | Discord bot user ID | | sendGatewayPayload | function | required | Discord gateway send function | | queueStore | QueueStoreManager | Memory | Queue persistence backend | | autoSkip | boolean | true | Auto-advance on track end/error | | autoResume | boolean | true | Enable session resuming | | destroyAfterMs | number | 30000 | Auto-destroy after queue end (ms) | | maxQueueSize | number | 10000 | Maximum tracks in queue | | maxPreviousTracks | number | 25 | Maximum history entries |

Penalty-Based Load Balancing

The client uses weighted penalty calculation for node selection:

| Component | Weight | Threshold | |-----------|--------|-----------| | Total Players | 1.0x | >100/node | | Playing Players | 2.5x | >50/node | | CPU Load | 3.0x | >70% | | Memory Ratio | 2.0x | >80% | | Frame Deficits | 5.0x | Any non-zero | | Frame Nulls | 3.0x | >10/update |

WebSocket Reconnection

Exponential backoff with jitter:

delay = min(base * 2^attempt + random(0, 0.5 * base * 2^attempt), 60000)

Parameters:

  • Base delay: 5s
  • Max delay: 60s
  • Jitter fraction: 50%

License

MIT License - see LICENSE for details.