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

@tecmie/techleadrpc

v0.0.6

Published

TypeSafe RPC client for techlead.so server

Readme

@tecmie/techleadrpc

Contract-first TypeScript RPC package for Techlead.so. This package exports type-safe contract definitions that both server and client can use to ensure end-to-end type safety.

Installation

npm install @tecmie/techleadrpc
# or
yarn add @tecmie/techleadrpc
# or
pnpm add @tecmie/techleadrpc

Philosophy

This package follows a contract-first approach where:

  1. Contracts are defined using oRPC and Zod schemas
  2. Server implements the contracts
  3. Clients consume the contracts with full type safety

We intentionally keep this package minimal and don't prescribe how you should set up your RPC connection. This gives you full control over authentication, headers, fetch configuration, and more.

Usage

Basic Setup

import { createORPCClient, RPCLink, type AppRouterClient } from '@tecmie/techleadrpc'

// Set up your RPC link with your own configuration
const link = new RPCLink({
  url: 'https://api.techlead.so/rpc',
  fetch(url, options) {
    return fetch(url, {
      ...options,
      credentials: 'include', // Your auth strategy
    })
  },
  headers: async () => {
    // Your custom headers
    return {
      'X-Custom-Header': 'value'
    }
  },
})

// Create a fully-typed client
const client: AppRouterClient = createORPCClient(link)

// Make RPC calls with full type safety
const health = await client.healthCheck()
const privateData = await client.privateData()

Next.js Integration

// app/utils/orpc.ts
import { createORPCClient, RPCLink, type AppRouterClient } from '@tecmie/techleadrpc'

export const link = new RPCLink({
  url: `${process.env.NEXT_PUBLIC_SERVER_URL}/rpc`,
  fetch(url, options) {
    return fetch(url, {
      ...options,
      credentials: 'include',
    })
  },
  headers: async () => {
    // Server-side: forward headers from incoming request
    if (typeof window === 'undefined') {
      const { headers } = await import('next/headers')
      return Object.fromEntries(await headers())
    }
    return {}
  },
})

export const client: AppRouterClient = createORPCClient(link)

// app/page.tsx
import { client } from '@/utils/orpc'

export default async function Page() {
  const data = await client.healthCheck()
  return <div>{data}</div>
}

TanStack Query Integration

import { createTanstackQueryUtils } from '@orpc/tanstack-query'
import { createORPCClient, RPCLink, type AppRouterClient } from '@tecmie/techleadrpc'

const link = new RPCLink({
  url: `${process.env.NEXT_PUBLIC_SERVER_URL}/rpc`,
  fetch(url, options) {
    return fetch(url, {
      ...options,
      credentials: 'include',
    })
  },
})

const client: AppRouterClient = createORPCClient(link)

// Create query utilities
export const orpc = createTanstackQueryUtils(client)

// Use in components
function Component() {
  const { data } = orpc.privateData.useQuery()
  return <div>{data?.message}</div>
}

Server Implementation

// server/src/lib/orpc.ts
import { implement } from '@orpc/server'
import { appContract } from '@tecmie/techleadrpc'

const os = implement(appContract)

export const publicProcedure = os.$context<Context>()

// server/src/routers/index.ts
export const appRouter = {
  healthCheck: publicProcedure.healthCheck.handler(() => {
    return 'OK' as const
  }),
  privateData: protectedProcedure.privateData.handler(({ context }) => {
    return {
      message: 'This is private',
      user: context.session?.user,
    }
  }),
}

Exports

Contracts

  • appContract - The root contract object
  • healthCheckContract - Health check procedure contract
  • privateDataContract - Private data procedure contract

Types

  • AppContract - Type of the contract object
  • AppRouterClient - Type-safe client interface
  • ContractRouterClient - Generic contract router client type
  • RouterClient - oRPC router client type

Client Utilities (Re-exported for version locking)

  • createORPCClient - Create an oRPC client from @orpc/client
  • RPCLink - RPC link for fetch-based connections from @orpc/client/fetch
  • onError - Error interceptor utility from @orpc/client
  • ClientLink - Client link type from @orpc/client

Why This Approach?

We believe in giving developers full control over their RPC setup. Instead of prescribing authentication strategies, header management, or fetch configuration, we:

  1. Export clean contracts - Just the type definitions and schemas
  2. Re-export oRPC utilities - Locked to compatible versions
  3. Let you configure everything - Full control over your RPC link setup

This makes the package:

  • Flexible - Use any auth strategy, any headers, any fetch config
  • Transparent - You see exactly how the connection is set up
  • Maintainable - No magic configuration or hidden defaults
  • Testable - Easy to mock and test your own setup

License

MIT