NEXIS
Getting started

Quickstart

Start stack, mint token, connect client, join room, send action.

Quickstart

This is the shortest end-to-end path that proves your setup is correct.

1. Start the stack

docker compose -f infra/docker-compose.yml up --build

Local endpoints:

  • control API: http://localhost:3000
  • dashboard: http://localhost:5173
  • data plane websocket: ws://localhost:4000

2. Create project and key

Use the dashboard UI at http://localhost:5173:

  1. Sign in with your operator account (NEXIS_DASHBOARD_ADMIN_EMAIL / NEXIS_DASHBOARD_ADMIN_PASSWORD)
  2. Create Project
  3. Create API Key for that project

Or use control API endpoints from your backend.

3. Mint client token

From dashboard (recommended for first run), or API:

curl -X POST http://localhost:3000/tokens \
  -H "content-type: application/json" \
  -d '{"project_id":"<project-id>","key_id":"<key-id>","ttl_seconds":3600}'

4. Connect and join room

import { connect } from "@triformine/nexis-sdk";

const client = await connect("ws://localhost:4000", {
  projectId: "<project-id>",
  token
});

const room = await client.joinOrCreate("counter_plugin_room", { roomId: "counter_plugin_room:default" });

5. Read initial state and react to patches

room.onStateChange((state) => {
  console.log("counter:", state.counter);
});

6. Send gameplay action

room.send("inc", { by: 1 });

Expected result:

  • room join succeeds
  • you receive state.snapshot first
  • each increment produces state.patch

If this fails, check Connect a Client and Auth in Real Games.

For dashboard usage details, see Dashboard.

Typed Quickstart Client

async function () {
  const  = await ('ws://localhost:4000', {
    : 'demo-project',
    : 'token',
  });

  const  = await .('counter_plugin_room', { : 'counter_plugin_room:default' });
  .('inc', { : 1 });
}

On this page