Prismarine Web Client
raw JSON →Prismarine Web Client is a browser-based Minecraft client that allows users to connect to and interact with Minecraft servers directly from a web page. It leverages the `mineflayer` library for high-level bot API interactions and `prismarine-viewer` for 3D world rendering within the browser. The current stable version is 1.6.0, with releases appearing somewhat frequently, indicating active development. A key differentiator is its ability to run entirely client-side in a web browser, connecting to standard Minecraft TCP servers via an intermediary WebSocket-to-TCP proxy that is bundled and managed by the CLI tool. This package is primarily distributed as a globally installable command-line tool that serves the client application, rather than a library intended for direct `import` into other JavaScript projects for code-level integration. Developers can interact with the running client's core functionalities, such as the `bot` instance and `viewer` for debugging and custom extensions, through global `window` objects.
Common errors
error ReferenceError: bot is not defined ↓
window.bot. error WebSocket connection to 'ws://localhost:XXXX/' failed: WebSocket is closed before the connection is established. ↓
prismarine-web-client is running in your terminal and listening on the expected port (default 8080). Check for any local firewall rules or network issues preventing connection to localhost. error Cannot find module 'prismarine-web-client' (e.g., in a Node.js project or another browser bundle) ↓
npm install -g prismarine-web-client followed by prismarine-web-client. If you intend to use underlying functionalities like the Minecraft client API or 3D viewer programmatically in a separate project, install and import mineflayer or prismarine-viewer directly. Warnings
gotcha The `prismarine-web-client` requires an intermediary WebSocket proxy (automatically handled by the CLI tool) to translate browser WebSocket connections to standard Minecraft TCP server connections. Direct connection to TCP servers from the browser is not possible due to browser security restrictions. ↓
gotcha Core API objects like `bot`, `viewer`, `mcData`, `worldView`, `Vec3`, and `debugMenu` are exposed as global variables on the `window` object within the served browser application (e.g., `window.bot`) for debugging and direct interaction. Attempting to `import` these directly as modules from the `prismarine-web-client` npm package will not work as expected. ↓
gotcha When developing locally using `npm start`, the Webpack build process will recompile the client application on every file save, which the README notes can take up to 5 seconds per change. This can significantly slow down the development feedback loop. ↓
Install
npm install prismarine-web-client yarn add prismarine-web-client pnpm add prismarine-web-client Imports
- bot wrong
import { bot } from 'prismarine-web-client'correctwindow.bot - viewer wrong
import { viewer } from 'prismarine-web-client'correctwindow.viewer - debugMenu wrong
import { debugMenu } from 'prismarine-web-client'correctwindow.debugMenu
Quickstart
npm install -g prismarine-web-client
# Run the client, which starts a web server and proxy
prismarine-web-client
# Open your browser and navigate to the client. Typically:
# http://localhost:8080
// --- Interact with the client in your browser's developer console ---
// Example: Send a chat message
// window.bot.chat('Hello from prismarine-web-client!');
// Example: Make the bot jump
// window.bot.entity.position.y += 5;
// Example: Find a diamond ore block within 256 blocks
// const diamondOrePos = window.bot.findBlock({
// matching: (block) => block.name === 'diamond_ore',
// maxDistance: 256
// });
// if (diamondOrePos) {
// console.log('Diamond ore found at:', diamondOrePos.position);
// } else {
// console.log('No diamond ore found nearby.');
// }