The Basics
Call any function from any function
rpc.invoke() calls another Pikku function by name — fully typed, with session inheritance.
const calculateTax = pikkuSessionlessFunc({
title: 'Calculate Tax',
func: async ({}, { amount, rate }) => {
return { tax: amount * rate }
}
})
const processOrder = pikkuFunc({
title: 'Process Order',
func: async ({ db }, { orderId }, { rpc }) => {
const order = await db.getOrder(orderId)
// Type-safe — input and output inferred
const { tax } = await rpc.invoke('calculateTax', {
amount: order.total,
rate: 0.08
})
return { orderId, total: order.total + tax }
}
})
Type-safe calls
Function name, input, and output are all inferred from your wirings
Session inherited
The caller's auth session propagates to the called function automatically
Depth tracked
rpc.depth increments on each call — built-in recursion protection
RPC Methods
Four ways to call
Internal, remote, exposed, or workflow — every call is type-safe and session-aware.
rpc.invoke(name, data)
internalCall a function from within the same instance. Session inherited, depth tracked.
rpc.remote(name, data)
remoteCall a function on another instance via DeploymentService. Session forwarded securely.
rpc.exposed(name, data)
exposedCall any function with expose: true. Used by public HTTP RPC endpoints.
rpc.startWorkflow(name, input)
workflowStart a workflow by name and get back a runId. Integrates with the workflow engine.
// Expose a function for external RPC calls
const greet = pikkuSessionlessFunc({
title: 'Greet',
expose: true, // ← makes it callable via rpc.exposed()
func: async ({}, { name }) => {
return { message: `Hello, ${name}!` }
}
})
// Public HTTP endpoint for RPC
wireHTTP({
route: '/rpc/:rpcName',
method: 'post',
auth: false,
func: rpcCaller,
})
Type-Safe Client
Typed RPC from the browser
Pikku generates a typed RPC client from your exposed functions. Invoke functions, start workflows, or call AI agents — all autocompleted.
import { pikkuRPC } from '.pikku/pikku-rpc.gen.js'
pikkuRPC.setServerUrl('http://localhost:4002')
// Fully typed — name, input, and output inferred
const result = await pikkuRPC.invoke('calculateTax', {
amount: 100,
rate: 0.08
})
// result.tax → number
// Auth: set a JWT for authenticated calls
pikkuRPC.setAuthorizationJWT(token)
Generated from wirings
PikkuRPC is auto-generated with typed overloads for every exposed function, workflow, and AI agent.
Namespaced addons
Call addon functions with namespace prefixes: rpc.invoke('stripe:createCharge', ...)
Start wiring RPC in 5 minutes
One command to scaffold a project with RPC wiring already configured.
MIT Licensed · Internal, remote & exposed RPC