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

@crowdedkingdomstudios/crowdyjs

v3.0.0

Published

Client SDK for Crowded Kingdoms GraphQL API with UDP proxy support

Readme

CrowdyJS SDK

Browser-first SDK for Crowded Kingdoms game clients. CrowdyJS wraps the GraphQL API, the UDP proxy subscription, auth/session state, and spatial send helpers in one typed client.

Install

npm install @crowdedkingdomstudios/crowdyjs

CrowdyJS v3 targets browsers by default and uses native fetch, WebSocket, crypto, btoa, and atob. Node tools can still use the SDK, but must provide browser-compatible globals when they open realtime connections.

Quick Start

import {
  BrowserLocalStorageTokenStore,
  createCrowdyClient,
} from '@crowdedkingdomstudios/crowdyjs';

const client = createCrowdyClient({
  httpUrl: 'https://api.example.com/graphql',
  wsUrl: 'wss://api.example.com/graphql',
  tokenStore: new BrowserLocalStorageTokenStore(),
  realtime: {
    retryAttempts: 8,
    waitTimeoutMs: 5000,
  },
});

await client.session.restore();

if (!client.session.getToken()) {
  await client.auth.login({ email: '[email protected]', password: 'secret' });
}

const bootstrap = await client.serverStatus.gameClientBootstrap('1');
console.log(bootstrap.versionInfo.minimumClientVersion);

Game Loop Lifecycle

  1. Authenticate with client.auth.login() or restore a previous token through client.session.restore().
  2. Subscribe to UDP proxy notifications with client.udp.subscribe() or client.realtime.connect().
  3. Join a chunk by sending an initial actor update.
  4. Send actor, voxel, text, audio, and client-event updates through client.udp or the higher-level client.world(appId) helpers.
  5. Call client.udp.disconnect() when leaving the world, then client.close() when disposing the SDK instance.

Realtime Notifications

const unsubscribe = client.udp.subscribe({
  actorUpdate: (event) => {
    console.log(event.uuid, event.state);
  },
  genericError: (event) => {
    console.warn(event.sequenceNumber, event.errorCode);
  },
  connectionEvent: (event) => {
    console.warn(event.code, event.message);
  },
  error: (error) => {
    console.error(error.code, error.message);
  },
});

client.realtime.onStatus((status) => {
  console.log('realtime:', status);
});

The SDK uses the graphql-transport-ws protocol through graphql-ws, reconnects with backoff, re-reads the current token before reconnecting, and resubscribes to the generated UdpNotifications document.

Raw UDP Sends

const response = await client.udp.sendActorUpdateAndWait({
  appId: '1',
  chunk: { x: '0', y: '0', z: '0' },
  uuid: '0123456789abcdef0123456789abcdef',
  state: 'AA==',
  distance: 8,
  decayRate: 1,
});

console.log(response.__typename, response.sequenceNumber);

The plain sendActorUpdate, sendVoxelUpdate, sendAudioPacket, sendTextPacket, and sendClientEvent methods return the GraphQL mutation result immediately. The AndWait variants allocate a sequenceNumber when one is missing and wait for either a matching notification or GenericErrorResponse.

World Helpers

const world = client.world('1');
const actor = world.actor();

await actor.join({ x: '0', y: '0', z: '0' });
await actor.sendState('AA==');
await actor.sendText('hello nearby players');

The world helpers are convenience wrappers for browser games. Advanced callers can always use client.udp.* with generated GraphQL input types.

Errors

Transport and protocol failures use structured error classes:

  • CrowdyHttpError
  • CrowdyGraphQLError
  • CrowdyNetworkError
  • CrowdyTimeoutError
  • CrowdyRealtimeError
  • CrowdyProtocolError

CrowdyGraphQLError preserves every GraphQL error, including path and extensions.code.

Low-Level GraphQL Access

Game-client methods are first-class, but generated operations are still available through the transport escape hatch:

import { VersionInfoDocument } from '@crowdedkingdomstudios/crowdyjs/generated';

const data = await client.graphql.request(VersionInfoDocument);

Most consumers should prefer the methods on client.auth, client.udp, client.serverStatus, client.users, client.apps, and client.world().

Development

npm install
npm run codegen
npm run build
npm test

npm run codegen syncs ../cks-graphql-api/schema.gql when the API repo is checked out beside this SDK. npm run check:schema fails if the committed SDL or generated types drift from the API schema.