TinyRPC
tinyRPC -> A minimal Typescript RPC framework . Protocol-agnostic inspired by trpc v10 and built for speed
Install / Use
/learn @renderffx/TinyRPCREADME
tinyRPC
A minimalist, RPC framework for TypeScript. Enables zero-overhead, end-to-end type safety between server and client by leveraging recursive type inference. This repository contains the complete framework source, multiple deployment adapters, and a comprehensive test suite.
core packages
- @tinyrpc/server: Core orchestration, procedure building, and runtime dispatch.
- @tinyrpc/client: Proxy-based client with functional link-chain architecture.
- @tinyrpc/react: Ergonomic React hooks built on TanStack Query.
server api reference
constructor
initTRPC.create<TConfig>(): Initializes the framework. Accepts configuration forctx,meta, andtransformer.
procedure building
.input(schema): Attaches a Zod or custom parser for incoming data..output(schema): Validates outgoing data before sending to the client..use(middleware): Chains recursive logic before the resolver..query(resolver): Definition for idempotent data fetching..mutation(resolver): Definition for state-changing operations..subscription(resolver): Definition for event-based streaming.
orchestration
t.router({ ... }): Groups procedures into a logical tree.t.mergeRouters(r1, r2): Merges nested router definitions.t.middleware(fn): Defines reusable context/logic wrappers.
client api reference
initialization
createTRPCProxyClient<Router>(opts): Creates the typed proxy.opts.links: An array of functional middleware (links).opts.transformer: Optional data serializer (e.g., handles Dates, BigInts).
functional links
httpLink: Unbatched Fetch-based transport.httpBatchLink: Merges concurrent requests to minimize network roundtrips.wsLink: Stateful WebSocket transport for real-timesubscriptionoperations.splitLink: Conditional routing based on operation type or path.retryLink: Resilient execution with jittered exponential backoff.cacheLink: Client-side caching with Stale-While-Revalidate (SWR).dedupeLink: Logic to prevent redundant inflight requests.loggerLink: Integrated observability for requests and responses.
react api reference
trpc.useQuery([input], [opts]): Standard data fetching hook.trpc.useMutation([opts]): State mutation hook.trpc.useSubscription(onData, [opts]): Real-time streaming hook.trpc.useUtils(): Context utility for cache invalidation and manual state updates.
available adapters
- Node.js:
createHTTPHandler(compatible withhttpandExpress). - Web/Edge:
fetchRequestHandler(compatible with Cloudflare Workers and Vercel Edge). - WebSockets:
applyWSHandler(Node.jswsintegration).
built-in examples
- basic-http (
examples/basic-http): Simple Node.js server using Fetch. - full-stack-ws (
examples/full-stack-ws): Bidirectional real-time communication. - analytics-dashboard (
examples/analytics-dashboard): High-load dashboard using Batching and SWR caching. - nextjs-app (
examples/nextjs-app): Integration with App Router and Turbopack. - edge-runtime (
examples/edge-runtime): Minimalist Cloudflare Worker deployment. - validation-test (
example/src/validation-test.ts): Technical demo of deep schema enforcement.
repository inventory
core source
packages/server/src: Dispatcher, Router, Middleware, and Adapters.packages/client/src: Proxy, Links, Observables, and Error handling.packages/react/src: Query wrapper, context hooks.
documentation & config
README.md: Technical specification and API overview.TEST_REPORT.md: Consolidated test metrics.tsconfig.json: Monorepo-wide TypeScript configuration.package.json: Dependency management and scripts.
test artifacts
tests/run-all-tests.ts: Central test orchestrator.tests/core-functionality.ts: Foundation tests.tests/links-tests.ts: Link-chain logic verification.tests/react-hooks.ts: Frontend hook integrity checks.tests/comprehensive-benchmark.ts: Throughput and overhead measurements.
verification commands
full sanity check
npm run test:all
runtime benchmarks
npm run test:benchmark
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
