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

nexus-rpc

v0.0.2

Published

Nexus TypeScript SDK

Readme

Nexus TypeScript SDK

CI API Docs

This SDK is currently at an experimental release stage. Backwards-incompatible changes are anticipated until a stable release is announced.

TypeScript SDK for working with Nexus RPC. See API documentation.

What is Nexus?

Nexus is a synchronous RPC protocol. Arbitrary duration operations are modeled on top of a set of pre-defined synchronous RPCs.

A Nexus caller calls a handler. The handler may respond inline (synchronous response) or return a token referencing the ongoing operation (asynchronous response). The caller can cancel an asynchronous operation, check for its outcome, or fetch its current state. The caller can also specify a callback URL, which the handler uses to deliver the result of an asynchronous operation when it is ready.

This SDK provides the core primitives for defining and implementing Nexus services in TypeScript.

Protocol Implementations

  • Temporal — builds on this SDK to provide a full implementation of the Nexus protocol, backed by Durable Execution.

Installation

npm install nexus-rpc

Usage

Define a Service

Use the service and operation helpers to define a typed service contract. Operations are generic in their input and output types.

import { service, operation } from "nexus-rpc";

interface MyInput {
  name: string;
}

interface MyOutput {
  greeting: string;
}

const myService = service("my-service", {
  sayHello: operation<MyInput, MyOutput>(),
});

Implement a Sync Operation

A sync operation handler is a function that receives a context and an input, and returns the output directly.

import { serviceHandler } from "nexus-rpc";

const handler = serviceHandler(myService, {
  async sayHello(ctx, input) {
    return { greeting: `Hello, ${input.name}!` };
  },
});

Implement an Async Operation

For operations that may take an arbitrary amount of time, return a HandlerStartOperationResult.async with a token that can be used to track, cancel, or deliver the result of the operation later.

import { HandlerStartOperationResult, serviceHandler } from "nexus-rpc";

const handler = serviceHandler(myService, {
  sayHello: {
    async start(ctx, input) {
      const token = await startBackgroundWork(input);
      return HandlerStartOperationResult.async(token);
    },
    async cancel(ctx, token) {
      await cancelBackgroundWork(token);
    },
  },
});

Resolve an Operation as Failed

Throw an OperationError from a start handler to indicate that the operation completed unsuccessfully.

import { OperationError } from "nexus-rpc";

// Failed operation
throw new OperationError("failed", "Not enough inventory");

// Canceled operation
throw new OperationError("canceled", "User canceled the operation");

Fail a Handler Request

Throw a HandlerError to fail a request with a specific error type. Returning an unrecognized error from any handler method will result in a generic internal server error response.

import { HandlerError } from "nexus-rpc";

// Bad request
throw new HandlerError("BAD_REQUEST", "Invalid input");

// Retryable internal error
throw new HandlerError("INTERNAL", "Database unavailable", {
  retryableOverride: true,
});

Contributing

Prerequisites

Build

pnpm install --frozen-lockfile
pnpm run build

Test

pnpm test

Lint

pnpm run lint

Format

pnpm run format