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

rpc-dart

v0.3.0

Published

TypeScript-to-Dart bindings generator for tRPC v11 backends.

Readme

rpc-dart

npm version license GitHub CI

CLI that reads your TypeScript tRPC v11 router and generates type-safe, build-tool-free Dart 3 bindings for Flutter and Dart clients.

Rename a procedure or edit a Zod schema on the backend: run generation, and the Dart analyzer immediately flags every outdated call site.

Part of the rpc-dart monorepo.


Why rpc-dart?

  • Zero Dart build runners: Generates plain Dart 3 classes with const constructors, copyWith, structural equality, and JSON serialization. You never run build_runner, freezed, or json_serializable.
  • Direct compiler extraction: Inspects your router with the TypeScript compiler API (ts.TypeChecker), preserving Zod transforms, defaults, discriminated unions, and three-state PATCH optionals (RpcOpt<T>).
  • Complete tRPC v11 wire protocol: Pairs with the trpc_dart runtime for HTTP batching, SuperJSON decoding (Date, BigInt, NaN), and structured exceptions.

Installation

# In your backend project:
npm install --save-dev rpc-dart
# or
pnpm add -D rpc-dart
# or
yarn add -D rpc-dart

Quickstart

1. Initialize configuration

Run the interactive setup in your backend directory:

npx rpc-dart init

This scans your workspace for router exports, tsconfig.json, and Flutter projects, then writes rpc-dart.config.ts:

import { defineConfig } from 'rpc-dart';

export default defineConfig({
  entry: './src/trpc/router.ts',
  exportName: 'appRouter',
  transformer: 'superjson',
  dart: {
    outDir: '../mobile/lib/src/api',
  },
});

2. Export your router type

Ensure your server exports both the router value and its type:

// src/trpc/router.ts
import { initTRPC } from '@trpc/server';
import superjson from 'superjson';

const t = initTRPC.create({ transformer: superjson });

export const appRouter = t.router({
  user: userRouter,
  posts: postsRouter,
});

export type AppRouter = typeof appRouter;

3. Generate bindings

# One-time generation:
npx rpc-dart generate

# Or watch mode during backend development:
npx rpc-dart watch

CLI Commands

| Command | Description | |---|---| | rpc-dart init | Interactive project setup; generates rpc-dart.config.ts. | | rpc-dart generate | Extracts the router contract and writes Dart bindings into outDir. | | rpc-dart watch | Watches backend router files and regenerates Dart on changes. | | rpc-dart check | Verifies committed Dart files match the backend router in CI. | | rpc-dart diff | Compares current router contract against a baseline to highlight breaking changes. | | rpc-dart clean | Safely deletes generated files tracked in .rpc-dart-manifest.json. | | rpc-dart doctor | Diagnoses configuration, compiler, and environment issues. |


Configuration Reference

rpc-dart.config.ts options:

import { defineConfig } from 'rpc-dart';

export default defineConfig({
  // Path to the TypeScript file exporting the router
  entry: './src/server/router.ts',

  // Name of the exported router constant (required; `init` guesses it for you)
  exportName: 'appRouter',

  // Extraction adapter: 'trpc' | 'orpc' | 'auto' (default).
  // 'auto' probes the export's shape (tRPC _def vs oRPC ~orpc).
  adapter: 'auto',

  // Transformer matching initTRPC ({ transformer })
  // Options: 'superjson' | 'json'
  transformer: 'superjson',

  // Dart output settings
  dart: {
    // Directory where generated Dart files will be written
    outDir: '../client/lib/src/api',
  },

  // Policy for unserializable or unknown types
  policies: {
    // Options: 'error' (default) | 'warn-dynamic' | 'skip-procedure'
    unserializablePolicy: 'error',
  },
});

Dart Runtime Setup

In your Flutter or Dart project, add trpc_dart:

dependencies:
  trpc_dart: ^0.3.0

Initialize the client with the generated Api class:

import 'package:trpc_dart/trpc_dart.dart';
import 'api/api.dart'; // generated directory

final client = RpcClient(
  endpoint: Uri.parse('https://api.example.com/trpc'),
  transformer: RpcTransformer.superjson,
  links: [
    HttpBatchLink(endpoint: Uri.parse('https://api.example.com/trpc')),
  ],
);

final api = Api(client);

Future<void> main() async {
  final user = await api.user.getById.query(UserGetByIdInput(id: 'u1'));
  print(user.name);
}

Links


License

MIT © Aditya Jandu