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 🙏

© 2025 – Pkg Stats / Ryan Hefner

bedrock-websocket-js

v3.1.0

Published

A WebSocket server for Minecraft Bedrock Edition, offering fully typed event handling, real-time player and game interactions, and seamless integration for JavaScript projects.

Readme

Bedrock WebSocket SDK

A high-performance Node.js SDK for real-time Minecraft: Bedrock Edition integration. Connect, track, and interact with your Minecraft world in real-time through WebSocket events.

🚀 Quick Start

Installation

npm install bedrock-websocket-js

Basic Setup (5 lines of code)

const { BedrockWebSocket } = require('bedrock-websocket-js');

const server = new BedrockWebSocket({ port: 8080 });

server.on('PlayerEvent:PlayerMessage', (player, message) => {
  console.log(`💬 ${player.name}: ${message}`);
});

Terminal output

[INFO]: WebSocket server started on port 8080
[INFO]: Players database initialized
[INFO]: Intervals started: 
 Heartbeat: 5m 0s,
 Sync: 1m 0s

[INFO]: 🟢 BEDROCK WEBSOCKET SERVER - OPERATIONAL
         ├─ Players: 0 online, 1 tracked
         ├─ Max Clients: 50 allowed
         ├─ Events: 12 monitored
         ├─ Heap Memory: 7MB used
         └─ Status: Ready for Minecraft connections

Connect Minecraft

/connect ws://localhost:8080

Cheats must be enabled • Requires operator permissions or by using PurePerms plugin

⚡ Real-Time Events Made Simple

Track Player Movements

server.on('PlayerEvent:PlayerTravelled', (player, vehicle, metadata) => {
  console.log(`📍 ${player.name} moved ${metadata.metersTravelled}m`);
  // Automatically tracks player position in cache
});

Monitor Player Actions

server.on('PlayerEvent:BlockPlaced', (player, block, tool) => {
  console.log(`${player.name} placed ${block.name}`);
});

server.on('PlayerEvent:ItemAcquired', (player, item) => {
  console.log(`${player.name} got ${item.count}x ${item.name}`);
});

Combat & Survival Events

server.on('PlayerEvent:MobKilled', (player, victim, weapon) => {
  console.log(`${player.name} killed ${victim.type} with ${weapon.name}`);
});

server.on('PlayerEvent:PlayerDied', (player, killer) => {
  console.log(`${player.name} died to ${killer?.type || 'unknown'}`);
});

🎯 Powerful Features

Instant Player Location Lookup

// Find players within 50 blocks (O(1) performance)
const nearby = server.CoordCache.getPlayersInRadius(
  { x: 100, y: 64, z: 200 }, 
  50, 
  'Overworld'
);

console.log(`Nearby players: ${nearby.map(p => p.username).join(', ')}`);

Send Commands to Players

// Send to specific player
server.commands.sendToPlayer('minecraft-Id', 'say Hello from code!');

// Broadcast to all players
server.commands.broadcastCommand('time set day');

Real Player Tracking

// Always know who's online
const onlinePlayers = server.players.getOnlinePlayers();
console.log(`Online: ${onlinePlayers.map(p => p.name).join(', ')}`);

Spatial Queries

// Find players in specific square area
const spawnPlayers = server.CoordCache.getPlayersInSquare(
  { x: 0, y: 64, z: 0 },      // Center point
  100,                        // 100x100 block area
  'Overworld'                 // Dimension
);

// Find players within 50 blocks of a point (circular area)
const nearbyPlayers = server.CoordCache.getPlayersInRadius(
  { x: 100, y: 64, z: 200 },  // Center point
  50,                         // Radius in blocks
  'Overworld'                 // Dimension
);

Built for Performance

  • O(1) Spatial Queries: Find players instantly with chunk-based indexing
  • Memory Efficient: Object pooling prevents garbage collection pressure
  • Production Ready: Handles 500+ concurrent players smoothly

🛠️ Configuration

const server = new BedrockWebSocket({
  port: 8080,                    // WebSocket port
  maxClients: 100,               // Maximum connections
  heartbeatInterval: 300000,     // 5-minute health checks
  databasePath: './players.db'   // Player data storage
});

🎮 Use Cases

  • Live Player Dashboards: Real-time player tracking and analytics
  • Automated Moderation: React to player actions instantly
  • Mini-game Servers: Build custom game mechanics
  • Stream Overlays: Show live game data on streams

🔗 Connect Instantly

  1. Install: npm install bedrock-websocket-js
  2. Code: Copy the examples above
  3. Connect: Use /connect ws://<ip>:8080 in Minecraft
  4. Build: Create amazing real-time features!

Perfect for: Server owners • Plugin developers • Educators • Streamers • Minecraft enthusiasts

No TypeScript required • Works with any Node.js project • MIT Licensed


Built with ❤️ for the Minecraft community