JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q86778F
  • License MIT

A WebSocket server for Minecraft Bedrock Edition, offering fully typed event handling, real-time player and game interactions, and seamless integration for JavaScript projects. ⚠ Under Development: This package is currently under active development. Features and APIs may change, and stability is not guaranteed. Use at your own risk.

Package Exports

  • bedrock-websocket-js
  • bedrock-websocket-js/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bedrock-websocket-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Bedrock WebSocket (JS)

A Node.js WebSocket server for interfacing with Minecraft: Bedrock Edition’s scripting runtime via the Minecraft Events WebSocket API

⚠️ Status: Under active development
The API is not yet stable. Breaking changes should be expected.

Overview

This library provides a typed, event-driven interface to subscribe to and handle in-game events (e.g., PlayerTravelled, ItemAcquired) emitted by a connected Minecraft client using /connect <URi> command. It is written in JavaScript and ships with TypeScript declaration files to support editor tooling (e.g., VS Code IntelliSense), without requiring TypeScript at runtime.

Installation

npm install bedrock-websocket-js

Usage

Step 1: Create a Websocket using BedrockWebSocket :

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

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

server.on('ItemAcquired', (player, item) => {
  console.log(`${player.name} acquired ${item.count} × ${item.name}`);
});

server.on('PlayerTravelled', (player, vehicle, metadata) => {
  console.log(`${player.name} moved ${metadata.metersTravelled}m`);
});

Step 2: Connect using in-game chat:

note: Cheats most be enabled in the world, Client most have operator permission.


1. open in-game chat
2. type /connect ws://ip:port 
     or /wsserver ws://ip:port

congratulation 🎉, you conncted to your Websocket

Ivmportant note

Typing Support

Type definitions are provided in index.d.ts and referenced via the "types" field in package.json. For full type-aware editing in JavaScript projects, ensure:

  • @types/node and @types/ws are installed as dev dependencies.
  • A jsconfig.json is present with "checkJs": true.

Structure

  • src/ — Entry point and server implementation
  • src/handlers/ — Event-specific logic
  • src/utils/ — Shared utilities
  • typings/index.d.ts — Ambient type declarations

© 2025 Yahya
Distributed under the MIT License.