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

meteor-rpc

v2.0.0

Published

End-to-end type-safe RPC (methods and publications) for Meteor, with optional React and TanStack Query hooks.

Readme

meteor-rpc

End-to-end type-safe methods and publications for Meteor, with TanStack Query hooks for React.

Define your API once on the server with any Standard Schema validator (zod, valibot, arktype, …). The client gets a fully typed object: autocomplete for every method, inputs checked at compile time and validated at runtime, and results typed from what your resolvers return. Inspired by tRPC and zodern:relay.

// server
const server = createModule()
  .addMethod("greet", z.object({ name: z.string() }), ({ name }) => `Hello, ${name}!`)
  .build();
export type Server = typeof server;

// client
const api = createClient<Server>();
const message = await api.greet({ name: "Ada" }); // string, autocompleted and type-checked

Upgrading from 1.x? Read MIGRATION.md. A codemod does most of the work.

Install

meteor npm install meteor-rpc zod @tanstack/react-query

| Requirement | Version | | --- | --- | | Meteor | 3.0 or later | | Validator | any Standard Schema: zod ≥ 3.24, valibot ≥ 1.0, arktype ≥ 2.0, … | | React + @tanstack/react-query (optional, for the hooks) | React 18.2+ or 19, TanStack Query 5 | | TypeScript (optional) | 5.0 or later. Works with @types/meteor, zodern:types and Meteor 3.6 native types. |

Quickstart

1. Define the API on the server

// imports/api/server.ts
import { Meteor } from "meteor/meteor";
import { createModule } from "meteor-rpc";
import { z } from "zod";
import { Tasks } from "./tasks"; // a Mongo.Collection

const tasks = createModule("tasks")
  .addMiddlewares([
    ({ userId }) => {
      if (!userId) throw new Meteor.Error("not-authorized");
    },
  ])
  .addMethod("add", z.object({ title: z.string().min(1) }), async ({ title }, { userId }) => {
    return Tasks.insertAsync({ title, done: false, owner: userId });
  })
  .addMethod("toggle", z.object({ id: z.string(), done: z.boolean() }), ({ id, done }) =>
    Tasks.updateAsync(id, { $set: { done } }),
  )
  .addPublication("mine", z.void(), (_input, { userId }) => Tasks.find({ owner: userId }))
  .buildSubmodule();

const server = createModule()
  .addMethod("ping", z.void(), () => "pong" as const)
  .addSubmodule(tasks)
  .build(); // registers everything with Meteor

export type Server = typeof server;
// server/main.ts
import "/imports/api/server";

2. Create the client once

// imports/api/client.ts
import { createClient } from "meteor-rpc";
import type { Server } from "./server"; // type-only: no server code reaches the client

export const api = createClient<Server>();

3. Use it in React

// imports/ui/App.tsx
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Suspense } from "react";
import { api } from "/imports/api/client";

const queryClient = new QueryClient();

export function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Suspense fallback={<p>Loading…</p>}>
        <Tasks />
      </Suspense>
    </QueryClientProvider>
  );
}

function Tasks() {
  const { data: tasks } = api.tasks.mine.usePublication(); // live data, suspends until ready
  const add = api.tasks.add.useMutation();
  const toggle = api.tasks.toggle.useMutation();

  return (
    <>
      <button type="button" onClick={() => add.mutate({ title: "New task" })} disabled={add.isPending}>
        Add
      </button>
      <ul>
        {tasks.map((task) => (
          <li key={task._id}>
            <input
              type="checkbox"
              checked={task.done}
              onChange={(event) => toggle.mutate({ id: task._id, done: event.target.checked })}
            />
            {task.title}
          </li>
        ))}
      </ul>
    </>
  );
}

Wrap the tree in an error boundary to show failures (for example react-error-boundary). Suspense hooks throw errors to the nearest one.

A complete app lives in examples/basic.

What you get

| On the server | On the client (api.<path>) | | --- | --- | | addMethod(name, schema, resolver, config?) | api.x(input), useQuery, useSuspenseQuery, useMutation, queryKey, queryOptions, mutationOptions | | addPublication(name, schema, resolver, config?) (one cursor) | usePublication(input) → { data, collection }, subscribe(input, callbacks), collection(input) | | addSharedPublication(name, schema, resolver, config?) (named cursors) | usePublication(input) → { data: { key: [] }, collections }, subscribe, collections(input) | | createModule("ns")…buildSubmodule() + addSubmodule | api.ns.x | | addMiddlewares([fn]), config.hooks, config.rateLimit | Errors as Meteor.Error; isValidationError(error) | | createCaller(module).x(input): call another module from server code | createClient<Server>({ suspense: true }): every useQuery suspends, so data is always defined |

Documentation

Entry points

| Import | Contains | Needs React | | --- | --- | --- | | meteor-rpc | everything below | yes | | meteor-rpc/server | createModule, server types | no | | meteor-rpc/client | createClient without hooks | no | | meteor-rpc/react | createClient with hooks | yes |

License

MIT