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

@meka-js/client

v0.0.13

Published

<img src="https://playmeka.com/meka-logo-black.svg" width="30%" />

Readme

meka-client

WebSocket-based client library for interacting with MEKA games.

Getting started

Install meka-client via Yarn:

yarn add @meka-js/client

Import classes from the library using es6:

import { MekaClient, GameClient } from "@meka-js/client";

If you'd like to see example code that uses meka-client, check out meka-boilerplate.

Examples

Connect to a game

import { MekaClient } from "@meka-js/client";
const meka = new MekaClient({
  gameId: "<Game ID>", // Required
  apiUrl: "<MEKA API URL>", // Optional
  webSocketUrl: "<MEKA WebSocket URL>", // Optional
  apiKey: "<Your MEKA API Key>", // Required
  apiSecret: "<Your MEKA API Secret>" // Required
});
meka.connect().then(() => console.log("Connected!"))

The connect function will wait until the MekaClient instance has authenticated with the API and downloaded the current version of the game.

Retrieve your user info

import { MekaClient } from "@meka-js/client";
const meka = new MekaClient({...});
await meka.connect(); // Done outside async function for demo purposes
const me = await meka.api.me();

Respond to events

import { MekaClient } from "@meka-js/client";
const meka = new MekaClient({...});
await meka.connect();
meka.on("start", () => console.log("Game started!"))

MekaClient is an event emitter, so you can react to a number of events. Here's the list:

  • tick: emitted every tick (500ms) with a list of executed actions and command responses.
  • download: when the game server sends the client a full download of the game.
  • connected: when the client has authenticated with the game server and downloaded its first version of the game.
  • addclient: when a new client connects to the game server.
  • closeclient: when a client disconnects fromthe game server.
  • joinuser: when a user joins the game, which is distinct from when a new client joins. The game can have an arbitrary number of clients, each affiliated with a user. But the game can only have two users (i.e. home and away).
  • readyuser: when a user marks themselves as ready to start the game.
  • ready: when all users have marked themselves as ready and the game will start in 5 seconds.
  • unready: when the game goes from a ready state to a not ready state. This usually happens when a user marks themselves as not ready or disconnects after being marked as ready.
  • start: when the game starts.
  • pause: when the game pauses, which usually happens when a game is in-progress and one of the users disconnects. If a user who disconnected reconnects within 30 seconds, the game resumes.
  • unpause: when the game resumes from being paused.
  • forfeit: when a user forfeits the game, usually due to a disconnection. Games are automatically forfeited if a user disconnects for 30 seconds.
  • end: when the game ends.

MekaClient status

The game server can be in one of five states:

  • open: the game is waiting for users to join.
  • ready: the game has users, they've all marked themselves as ready, and the game will be starting in 5 seconds.
  • inprogress: the game is underway and can receive actions.
  • paused: the game is paused.
  • ended: the game has ended.

Sending commands

When you want to send a command on behalf of one of your users, here is an example to follow:

import { MekaClient } from "@meka-js/client";
import { Citizen, Position, MoveCommand } from "@meka-js/core";
const meka = new MekaClient({...});
await meka.connect();
const citizen = new Citizen(meka.game, {...});
const newPosition = new Position(10, 10);
const command = new MoveCommand({ unit: citizen, args: {position: newPosition} });
meka.sendCommand(command);