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

@arrirpc/codegen-ts

v0.81.1

Published

## Setup

Downloads

400

Readme

Arri Typescript Codegen

Setup

1) Add the generator to your arri config

// arri.config.ts
import { defineConfig, generators } from 'arri';

export default defineConfig({
    generators: [
        generators.typescriptClient({
            clientName: 'MyClient',
            outputFile: './client/src/myClient.g.ts',
        }),
    ],
});

Options:

| Name | Description | | --------------------- | ---------------------------------------------------------- | | outputFile (required) | Path to a file that will be created by the generator | | clientName | The name of the generated client | | typePrefix | Add a prefix to the generated type names | | rootService | Set the root service of the generated client | | prettierOptions | Formatting options for the generated code | | rpcGenerators | Override the default function used for creating procedures |

2) Install the TS client library

Make sure that the project that will be using the generated code has the client library installed. The version number should match your arri cli version.

# npm
npm i @arrirpc/client

# pnpm
pnpm i --save @arrirpc/client

Using the Generated Code

Initialize the client

// This will match whatever you put in the arri config
import { MyClient } from './myClient.g';

const client = new MyClient({
    // only required field
    baseUrl: 'https://example.com',

    // everything below is optional
    headers: () => {
        return {
            Authorization: '<some-token>',
        };
    },
    onError: (err) => {},
    options: {
        retry: 4,
        retryDelay: 200,
        retryStatusCodes: [400, 403, 500, 501],
        onRequest: (ctx) => {},
        onRequestError: (ctx) => {},
        onResponse: (ctx) => {},
        onResponseError: (ctx) => {},
        signal: undefined, // abortcontroller signal
        timeout: 200,
    },
});

await client.myProcedure({ foo: 'foo' });

// individual procedures can also override the global request options
await client.myProcedure({ foo: 'foo' }, { timeout: 400 });
// be aware that these options are not merged with the global request options so you will have to
// re-specify every hook if you only want to change one thing

The root client will be a class containing all of the services and procedures in a single class. If you only need a particular service. You can also import just that service.

For example if we have a some procedures grouped under "users" we can import just that service like so.

import { MyClientUsersService } from './myClient.g';

const usersService = new MyClientUsersService({
    baseUrl: 'https://example.com',
    headers: () => {
        return {
            Authorization: '<some-token>',
        };
    },
});

usersService.someProcedure();

Importing and using types

All generated types and serializers/parsers can be imported from the generated code as well. Types will match the ID given to them in the schema. Serialization and parsing helpers will be prefixed with a $$

// import the user type and the user helper
import { type User, $$User } from './myClient.g';

const bob: User = {
    // field
};

$$User.serialize(bob); // outputs valid JSON
$$User.parse('<some-json-string>'); // outputs a User

Development

Building

Run nx build ts-codegen to build the library.

Running unit tests

Run nx test ts-codegen to execute the unit tests via Vitest.