Introduction
Lightweight, framework-agnostic TypeScript RPC with end-to-end type safety.
kibinrpc is a TypeScript RPC library that gives you a fully typed client inferred directly from your server implementation — no code generation, no schema files, no manual type duplication.
How it works
Define server actions, create a router, and mount a single handler. The client proxy is typed by the server's router type, so method signatures, parameters, and return types all flow through automatically.
POST /api/rpc → { namespace, method, args }
← { data } | { error }
POST /api/rpc → [{ namespace, method, args }, ...] (auto-batched)
← [{ data, status }, ...]Calls that happen concurrently (e.g. inside Promise.all) are automatically coalesced into a single HTTP request. No explicit batching API is needed.
Packages
@kibinrpc/server
Router, action registration, interceptors
@kibinrpc/client
Type-safe fetch client with auto-batching and retry
Quick example
Server
import { ServerAction, createRouter } from '@kibinrpc/server'
class UserActions {
@ServerAction()
async getUser(id: string) {
return db.users.find(id)
}
}
export const router = createRouter({ user: new UserActions() })
export type AppRouter = typeof routerClient
import { createKibinClient } from '@kibinrpc/client'
import type { AppRouter } from './server/router'
const client = createKibinClient<AppRouter>({ baseUrl: '/api/rpc' })
// Return type is inferred as the actual return type of getUser
const user = await client.user.getUser('1')