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-jsUsage
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 WebsocketIvmportant 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/nodeand@types/wsare installed as dev dependencies.- A
jsconfig.jsonis present with"checkJs": true.
Structure
src/— Entry point and server implementationsrc/handlers/— Event-specific logicsrc/utils/— Shared utilitiestypings/index.d.ts— Ambient type declarations
© 2025 Yahya
Distributed under the MIT License.