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

@travelerdev/orpc-fastify

v0.1.1

Published

A Fastify plugin for integrating [ORPC](https://orpc.unnoq.com/) with Fastify servers. This package provides seamless integration between ORPC's type-safe RPC system and Fastify's high-performance web framework.

Downloads

3

Readme

@travelerdev/orpc-fastify

A Fastify plugin for integrating ORPC with Fastify servers. This package provides seamless integration between ORPC's type-safe RPC system and Fastify's high-performance web framework.

Features

  • 🔌 Fastify Plugin: Easy integration with Fastify applications
  • 🎯 Type-Safe RPC: Full TypeScript support with ORPC's type system
  • 🚀 High Performance: Leverages Fastify's speed and ORPC's efficiency
  • 🔧 Flexible Context: Customizable request context creation
  • 📡 Standard Protocol: Compatible with ORPC's standard server implementation
  • 🛡️ Strict GET Method: Built-in protection against unsafe GET requests

Installation

npm install @travelerdev/orpc-fastify

Peer Dependencies

This package requires the following peer dependencies:

  • @orpc/server: ^1.8.8
  • fastify: ^5.6.0

Quick Start

import Fastify from "fastify";
import { orpc } from "@travelerdev/orpc-fastify";
import { createRouter } from "@orpc/server";

// Create your ORPC router
const router = createRouter().query("hello", {
  input: z.object({ name: z.string() }),
  output: z.string(),
  handler: async ({ input }) => `Hello, ${input.name}!`,
});

// Create Fastify instance
const fastify = Fastify();

// Register the ORPC plugin
await fastify.register(orpc, {
  router,
  createContext: async ({ req }) => {
    // Create your request context here
    return {
      userId: req.headers["user-id"] as string,
      // ... other context properties
    };
  },
  prefix: "/api", // Optional: prefix for all routes
});

// Start the server
await fastify.listen({ port: 3000 });

API Reference

orpc Plugin

The main plugin function that registers ORPC with Fastify.

Options

interface FastifyORPCPluginOptions<R extends Router<any, Context>> {
  prefix?: `/${string}` | undefined; // Route prefix (optional)
  router: R; // ORPC router instance
  createContext: (args: {
    req: FastifyRequest;
  }) => Promise<Context | undefined>; // Context factory
  context?: Context | undefined; // Base context (optional)
  strictGetMethodPluginEnabled?: boolean; // Enable strict GET method protection (default: true)
}

Parameters

  • router: Your ORPC router instance containing all your RPC procedures
  • createContext: Function that creates request-specific context from Fastify request
  • prefix: Optional URL prefix for all ORPC routes (e.g., /api)
  • context: Optional base context that will be merged with request-specific context
  • strictGetMethodPluginEnabled: Whether to enable strict GET method protection (default: true)

FastifyHandler

Internal class that handles the integration between Fastify and ORPC's standard server.

Advanced Usage

Custom Context Creation

await fastify.register(orpc, {
  router,
  createContext: async ({ req }) => {
    // Extract user information from request
    const token = req.headers.authorization?.replace("Bearer ", "");
    const user = await validateToken(token);

    return {
      user,
      requestId: req.id,
      timestamp: new Date(),
    };
  },
});

Base Context

await fastify.register(orpc, {
  router,
  context: {
    appVersion: "1.0.0",
    environment: process.env.NODE_ENV,
  },
  createContext: async ({ req }) => {
    return {
      userId: req.headers["user-id"] as string,
    };
  },
});

Custom Prefix

await fastify.register(orpc, {
  router,
  prefix: "/rpc/v1",
  createContext: async ({ req }) => ({}),
});

Related Packages