SkillAgentSearch skills...

Kkrpc

A TypeScript RPC protocol for multiple environments (iframe, web worker, stdio, http, WebSocket)

Install / Use

/learn @kunkunsh/Kkrpc
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<div align="center">

🚀 kkrpc

TypeScript-First RPC Library

Ask DeepWiki zread NPM Version JSR Version License Downloads GitHub stars Typedoc Documentation Excalidraw Diagrams LLM Docs

</div>

This project was created for building extension system for a Tauri app (kunkun).

It can potentially be used in other types of apps, so I open sourced it as a standalone package.

Seamless bi-directional communication between processes, workers, and contexts

Call remote functions as if they were local, with full TypeScript type safety and autocompletion support.

Similar to Comlink but with bidirectional communication and support for multiple environments - both client and server can expose functions for the other to call across Node.js, Deno, Bun, and browser environments.

Quick StartDocumentationExamplesAPI ReferenceLLM Docs中文文档

🎥 Video Tutorial

kkrpc Tutorial

Watch this video for a comprehensive introduction to kkrpc and how to use it in your projects.

🤖 AI Support

Working with kkrpc in your AI-powered editor? Add these skills to your Claude Code configuration to get intelligent assistance:

# Copy kkrpc skills to your global Claude Code skills folder
cp -r skills/kkrpc ~/.claude/skills/
cp -r skills/interop ~/.claude/skills/

This provides your AI assistant with:

  • kkrpc skill: How to use kkrpc in TypeScript projects
  • interop skill: How to implement kkrpc clients/servers in other languages (Go, Python, Rust, Swift)

See skills/ directory for details.

<div align="center"> <img src="https://imgur.com/19XswxO.jpg" style="max-width: 800px; width: 100%; margin-bottom: 20px;"/> <img src="https://imgur.com/vR3Lmv0.png" style="max-height: 200px; margin: 10px;"/> <img src="https://i.imgur.com/zmOHNfu.png" style="max-height: 250px; margin: 10px;"/> <img src="https://imgur.com/u728aVv.png" style="max-height: 400px; margin: 10px;"/> <img src="https://i.imgur.com/Gu7jH1v.png" style="max-height: 300px; margin: 10px;"/> </div>

🌟 Why kkrpc?

kkrpc stands out in the crowded RPC landscape by offering true cross-runtime compatibility without sacrificing type safety or developer experience. Unlike tRPC (HTTP-only) or Comlink (browser-only), kkrpc enables seamless communication across Node.js, Deno, Bun, and browser environments.

✨ Features

<div align="center">

| Feature | Description | | --------------------------- | -------------------------------------------------------------- | | 🔄 Cross-runtime | Works seamlessly across Node.js, Deno, Bun, browsers, and more | | 🛡️ Type-safe | Full TypeScript inference and IDE autocompletion support | | ↔️ Bidirectional | Both endpoints can expose and call APIs simultaneously | | 🏠 Property Access | Remote getters/setters with dot notation (await api.prop) | | 💥 Error Preservation | Complete error objects across RPC boundaries | | 🌐 Multiple Transports | stdio, HTTP, WebSocket, postMessage, Chrome extensions | | 📞 Callback Support | Remote functions can accept callback functions | | 🔗 Nested Calls | Deep method chaining like api.math.operations.calculate() | | 📦 Auto Serialization | Intelligent JSON/superjson detection | | ⚡ Zero Config | No schema files or code generation required | | 🔒 Data Validation | Optional runtime validation with Zod, Valibot, ArkType, etc. | | 🔌 Middleware | Interceptor chain for logging, auth, timing, and more | | ⏱️ Request Timeout | Auto-reject pending calls after a configurable deadline | | 🔁 Streaming | Return AsyncIterable from methods, consume with for await | | 🚀 Transferable Objects | Zero-copy transfers for large data (40-100x faster) |

</div>

🌍 Supported Environments

<div align="center">
graph LR
	A[kkrpc] --> B[Node.js]
	A --> C[Deno]
	A --> D[Bun]
	A --> E[Browser]
	A --> F[Chrome Extension]
	A --> G[Tauri]

	B -.-> H[stdio]
	C -.-> H
	D -.-> H

	E -.-> I[postMessage]
	E -.-> J[Web Workers]
	E -.-> K[iframes]

	F -.-> L[Chrome Ports]

	G -.-> M[Shell Plugin]

	style A fill:#ff6b6b,stroke:#333,stroke-width:2px
</div>

📡 Transport Protocols

| Transport | Use Case | Supported Runtimes | | -------------------- | ----------------------------------------------------- | -------------------------------------- | | stdio | Process-to-process communication | Node.js ↔ Deno ↔ Bun | | postMessage | Browser context communication | Browser ↔ Web Workers ↔ iframes | | HTTP | Web API communication | All runtimes | | WebSocket | Real-time communication | All runtimes | | Hono WebSocket | High-performance WebSocket with Hono framework | Node.js, Deno, Bun, Cloudflare Workers | | Socket.IO | Enhanced real-time with rooms/namespaces | All runtimes | | Elysia WebSocket | Modern TypeScript framework WebSocket integration | Bun, Node.js, Deno | | Chrome Extension | Extension component communication | Chrome Extension contexts | | RabbitMQ | Message queue communication | Node.js, Deno, Bun | | Redis Streams | Stream-based messaging with persistence | Node.js, Deno, Bun | | Kafka | Distributed streaming platform | Node.js, Deno, Bun | | NATS | High-performance messaging system | Node.js, Deno, Bun | | Electron | Desktop app IPC (Renderer ↔ Main ↔ Utility Process) | Electron |

The core of kkrpc design is in RPCChannel and IoInterface.

  • RPCChannel is the bidirectional RPC channel
  • LocalAPI is the APIs to be exposed to the other side of the channel
  • RemoteAPI is the APIs exposed by the other side of the channel, and callable on the local side
  • rpc.getAPI() returns an object that is RemoteAPI typed, and is callable on the local side like a normal local function call.
  • IoInterface is the interface for implementing the IO for different environments. The implementations are called adapters.
    • For example, for a Node process to communicate with a Deno process, we need NodeIo and DenoIo adapters which implements IoInterface. They share the same stdio pipe (stdin/stdout).
    • In web, we have WorkerChildIO and WorkerParentIO adapters for web worker,

Related Skills

View on GitHub
GitHub Stars155
CategoryDevelopment
Updated6d ago
Forks5

Languages

TypeScript

Security Score

100/100

Audited on Mar 27, 2026

No findings