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

@nexhub/vite-rspc-plugin

v0.1.2

Published

A vite plugin for auto-generating dedicated functions for RSPC per query, mutation, and subscription with typescript

Readme

@nexhub/vite-rspc-plugin

A Vite plugin for auto-generating dedicated functions for RSPC per query, mutation, and subscription with TypeScript.

Description

This plugin simplifies the process of generating RPC (Remote Procedure Call) code from RSPC. It automatically generates TypeScript functions for each query, mutation, and subscription defined in your RSPC configuration. This ensures type safety and reduces boilerplate code in your Vite projects.

Why

  • Type Safety: Automatically generates TypeScript functions with proper types.
  • Reduce Boilerplate: No need to manually write RPC functions.
  • Easy Integration: Seamlessly integrates with Vite and RSPC.

Getting Started

Installation

To install the plugin, use one of the following command for your package manager:

# One of the following 
npm install -D @nexhub/vite-rspc-plugin

pnpm add -D @nexhub/vite-rspc-plugin

yarn add -D @nexhub/vite-rspc-plugin

bun add -D @nexhub/vite-rspc-plugin

deno install -D jsr:@nexhub/vite-rspc-plugin

Usage

Next, in your vite.config.ts, you'll need to add and configure your plugin like so

import { defineConfig } from "vite";
import RSPC from "./vite-plugin-rspc";

export default defineConfig({
  plugins: [
    RSPC({
      input: "./src/types/backend.d.ts",
      client: {
        // Where your rspc is being served
        transport: "http://localhost:4000/rspc"
      },
      output: "./src/logic/backend.ts",
    }),
  ],
});

Generated

The output in your configuration will look something like the following:


/* Auto-generated file - do not edit */
/* eslint-disable */

import type * as rpc from '/absolute/path/to/src/types/backend.d.ts';
import { createClient, FetchTransport, type Client } from "@rspc/client";

// Generated Client and Config
const transport = new FetchTransport("http://localhost:4000/rspc");
const clientConfig = {...{}, transport};
export const client = createClient<rpc.Procedures>(clientConfig);

/** 
 * query RPC call to `hello`
 * @param input {rpc.Info}
 * @returns {string}
 */
export function hello(input: rpc.Info) {
  return client.query(["hello", input]);
}

/** 
 * query RPC call to `user.list`
 * Takes no input
 * @returns {void}
 */
export function userList() {
  return client.query(["user.list"]);
}

/** 
 * query RPC call to `version`
 * Takes no input
 * @returns {string}
 */
export function version() {
  return client.query(["version"]);
}

Each RPC is its own function that can be imported and used however you like. If there is an overlap in names then you can specific a prefix or a default one will be used (query, mutation, subscribeTo)

It is recommened to NOT commit the generated file as it contains the aboslute path to the input file. At some point I may make it relative which will change this recommenedation.

Configuration

The plugin accepts the following configuration options:

| Option | Type | Description | Default Value | |-----------------------------|-----------|------------------------------------------------|--------------------------| | input | string | The path to the RSPC types file. | undefined | | output | string | The path where the generated RPC code. | undefined | | client.transport | string | The transport URL for the RPC client. | "http://localhost:4000/rspc" (dev) or "/rspc" (prod) | | func.prefix.query | string | Prefix for query functions. | "query" | | func.prefix.mutation | string | Prefix for mutation functions. | "mutate" | | func.prefix.subscription | string | Prefix for subscription functions. | "subscribeTo" | | func.prefixDuplicatesOnly | boolean | Whether to prefix only duplicate function names. | true |

These are only bespoke types. Client for example has more fields since it extends type Client in @rspc/client. See src/types.d.ts for more insight if needed.

Example Configuration

createRSPCPlugin({
  input: './path/to/rspc/types.d.ts',
  output: './path/to/generated/rpc.ts',
  client: {
    transport: '/api/rpc',
  },
  func: {
    prefix: {
      query: 'query',
      mutation: 'mutate',
      subscription: 'subscribeTo',
    },
    prefixDuplicatesOnly: true,
  },
});

Contributing

Feel free to make a PR to main without asking,. I'm unlike to say no if its useful changes to someone. Security and linting checks will take place automatically via CI.

Licence

This project is licensed under the MIT License