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

@irtio/server

v4.8.0

Published

irtio room-file API: defineRoom, handler and ctx types

Downloads

3,213

Readme

@irtio/server

Write multiplayer room logic with typed state, lifecycle handlers, validation, and RPCs. defineRoom produces the room definition that the irtio CLI runs and deploys.

npm install @irtio/server @irtio/schema
npm install --save-dev irtio

Define a room

Create irtio/schema.ts:

import { defineSchema, entity, f32 } from '@irtio/schema';

export const schema = defineSchema(
  { players: entity({ x: f32, y: f32 }) },
  { roles: ['player'] as const },
);

Create irtio/room.ts:

import { defineRoom } from '@irtio/server';
import { schema } from './schema.js';

export default defineRoom(schema, {
  mode: 'tick',
  tickRate: 20,
  tick() {},
  onJoin(state, ctx) {
    if (ctx.reconnecting) return;
    state.players.add(ctx.clientId, { x: 0, y: 0 }, { owner: ctx.clientId });
  },
  onLeave(state, ctx) {
    state.players.remove(ctx.clientId);
  },
});
npx irtio dev

Each joining client gets a player record it owns. Other clients receive its updates. Use the client SDK to join and draw the room.

Choose where logic runs

| Configuration | Purpose | | --- | --- | | mode: 'tick', tickRate | Run a fixed-rate simulation; tickRate is ticks per second | | mode: 'event' | Process incoming actions without a continuous tick loop | | onAdmit | Admit or refuse a join before allocating a seat | | onJoin, onLeave | Create and remove per-connection state | | validate | Check client-owned writes against your game rules | | rpc | Implement the server RPCs declared in your schema | | onWake | Restore application behavior after hibernation |

Room handlers are synchronous. Start asynchronous storage operations and handle their results in continuations. Use ctx.deny(reason) for an expected RPC refusal, and keep durable values in schema state or player storage rather than module variables.

The room configuration reference lists every option. The server room API covers handler contexts, storage, timers, messages, and errors.