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

@douglance/stdb-standard-types

v1.0.0

Published

Strictly-typed foundation for SpacetimeDB modules, eliminating implicit any types

Readme

@spacetimedb/standard-types

Strictly-typed foundation for SpacetimeDB modules, eliminating implicit any types and providing rich IntelliSense.

Problems Solved

  • Implicit any types for ctx and args in reducers and systems
  • Lack of autocomplete for ctx.db tables and their methods
  • Confusion around ctx.timestamp object vs. a primitive bigint

Installation

npm install @spacetimedb/standard-types

Usage

Before: Untyped, Error-Prone

// ❌ No type safety, no autocomplete, runtime errors
export function joinGame(ctx, args) {
  ctx.db.PlayerTag.insert({ entity_id: ctx.sender, name: args.name });
}

Problems:

  • No compile-time errors if table name is wrong (PlayerTag vs playerTag)
  • No autocomplete for ctx.db properties
  • No validation of args shape
  • Implicit any types everywhere

After: Fully Typed

import type { ReducerContext } from "@spacetimedb/standard-types";
import type { GameSchema } from "../generated/schema";

type JoinGameArgs = { name: string };

// ✅ Full type safety, compile-time errors, full autocomplete
export function joinGame(ctx: ReducerContext<GameSchema, JoinGameArgs>, args: JoinGameArgs) {
  // TypeScript autocomplete shows `ctx.db.playerTag`, not `PlayerTag`
  // ❌ Compile Error if wrong: Property 'PlayerTag' does not exist on type 'DbView<GameSchema>'
  ctx.db.playerTag.insert({
    entity_id: ctx.sender,
    name: args.name,
    color: "#FF0000",
  });
}

Benefits:

  • Compile-time errors catch typos in table names
  • Full IntelliSense autocomplete for all tables and methods
  • Args are validated at compile time
  • No implicit any types

API Reference

SpacetimeSchema

Base type for a generated schema object.

export type SpacetimeSchema = {
  db: Record<string, {
    insert: (row: any) => void;
    update: (row: any) => void;
    delete: (row: any) => void;
    find: (pk: any) => any | undefined;
    iter: () => Iterable<any>;
  }>;
};

DbView<S>

The fully typed database view based on a schema.

export type DbView<S extends SpacetimeSchema> = S["db"];

ReducerContext<S, Args>

The context passed to reducers, generic over the schema and reducer arguments.

export type ReducerContext<
  S extends SpacetimeSchema,
  Args extends Record<string, any> = {}
> = {
  readonly sender: SpacetimeIdentity;
  readonly timestamp: SpacetimeTimestamp;
  readonly connectionId: SpacetimeConnectionId | null;
  readonly db: DbView<S>;
  readonly args: Args;
};

SystemContext<S>

The context passed to systems.

export type SystemContext<S extends SpacetimeSchema> = {
  readonly timestamp: SpacetimeTimestamp;
  readonly db: DbView<S>;
};

ClientLifecycleContext<S>

Context for client connection/disconnection hooks.

export type ClientLifecycleContext<S extends SpacetimeSchema> = {
  readonly sender: SpacetimeIdentity;
  readonly connectionId: SpacetimeConnectionId;
  readonly db: DbView<S>;
};

Example: Full Module

import { schema, table, t } from "spacetimedb/server";
import type { ReducerContext, SystemContext, ClientLifecycleContext } from "@spacetimedb/standard-types";

// Define schema
const PlayerTag = table({ name: 'PlayerTag', public: true }, {
  entity_id: t.identity().primaryKey(),
  name: t.string(),
});

const Position = table({ name: 'Position', public: true }, {
  entity_id: t.identity().primaryKey(),
  x: t.f32(),
  y: t.f32(),
});

export const gameSchema = schema(PlayerTag, Position);
export type GameSchema = typeof gameSchema;

// Fully typed reducer
type JoinGameArgs = { name: string };

export function joinGame(ctx: ReducerContext<GameSchema, JoinGameArgs>, args: JoinGameArgs) {
  ctx.db.playerTag.insert({ entity_id: ctx.sender, name: args.name });
  ctx.db.position.insert({ entity_id: ctx.sender, x: 0, y: 0 });
}

// Fully typed system
export function updatePhysics(ctx: SystemContext<GameSchema>) {
  for (const pos of ctx.db.position.iter()) {
    // Physics logic with full type safety
  }
}

// Fully typed lifecycle hook
export function handleConnect(ctx: ClientLifecycleContext<GameSchema>) {
  console.log("Client connected:", ctx.sender);
}

License

MIT