
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
A small TypeScript-first RPC library with acknowledgements, middleware, configurable timeouts and a fluent call builder.
bun install
import { createNirpc } from "nirpc";
interface RemoteFunctions {
hello: (name: string) => string;
calculate: (a: number, b: number) => number;
}
const rpc = createNirpc<RemoteFunctions>({}, {
post: async (data) => {
// Send to remote (WebSocket, postMessage, etc.)
},
on: (fn) => {
// Listen for incoming messages
},
});
Direct call:
const result = await rpc.hello("World");
With per-call options using the builder hanging off the method:
const sum = await rpc.calculate
.options({
timeout: 2000,
ackTimeout: 500,
retry: 3,
})
.run(10, 20);
Middleware runs before each request and can inspect or modify the outgoing message:
const rpc = createNirpc<RemoteFunctions>({}, {
post: async (data) => { /* ... */ },
on: (fn) => { /* ... */ },
middleware: (req) => {
return {
...req,
// attach metadata, auth tokens, etc.
};
},
});
createNirpc can send an acknowledgement as soon as a request is received, before the handler runs. Timeouts are configurable both for the acknowledgement and for the handler result:
const rpc = createNirpc<RemoteFunctions>({}, {
post: async (data) => { /* ... */ },
on: (fn) => { /* ... */ },
ackTimeout: 5000,
timeout: 30000,
onAckTimeoutError: (functionName, args) => {
console.error(`No acknowledgement for ${functionName}`, args);
// return true to suppress throwing the error
},
});
createNirpcCreates an RPC instance:
const rpc = createNirpc<RemoteFunctions, LocalFunctions>(localFunctions, {
post,
on,
off,
serialize,
deserialize,
bind,
eventNames,
timeout,
ackTimeout,
resolver,
middleware,
onRequest,
onError,
onFunctionError,
onGeneralError,
onTimeoutError,
onAckTimeoutError,
});
Each remote function is exposed as:
rpc.method(...args) – regular call returning a promiserpc.method.asEvent(...args) – fire-and-forgetrpc.method.options({ timeout?, ackTimeout?, retry? }).run(...args) – call with per-invocation optionsAdditional helpers:
rpc.$call(name, ...args)rpc.$callOptional(name, ...args)rpc.$callEvent(name, ...args)rpc.$builder(name) – lower-level builder (params().timeout().ackTimeout().retry().execute())rpc.$close(error?)rpc.$rejectPendingCalls(handler?)createNirpcGroupFor broadcasting the same call to multiple channels:
import { createNirpcGroup } from "nirpc";
const group = createNirpcGroup<RemoteFunctions>(localFunctions, () => channels, {
timeout: 10_000,
});
await group.broadcast.processEvent("payload");
await group.broadcast.processEvent.asEvent("payload");
Run the examples in this repo with:
bun run examples.ts
MIT
FAQs
Unknown package
The npm package nirpc receives a total of 2 weekly downloads. As such, nirpc popularity was classified as not popular.
We found that nirpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.