Skip to content

IRPCIsomorphic Remote Procedure Call

Write once, run anywhere. Truly isomorphic, zero-boilerplate remote procedure calls.

/irpc/fs.ts

typescript
import { irpc } from './irpc';

type ReadFile = (path: string) => Promise<string>;

export const readFile = irpc<ReadFile>({
  name: 'readFile',
});

/api/fs.ts

typescript
import { fs } from 'node:fs/promises';
import { irpc } from '../irpc/irpc';
import { readFile } from '../irpc/fs';

irpc.construct(readFile, async (path) => {
  return await fs.readFile(path, 'utf8');
});

/app/App.tsx

tsx
import { readFile } from '../irpc/fs';

export default function App() {
  const [content, setContent] = useState('');

  useEffect(() => {
    readFile('file.txt').then(setContent);
  }, []);

  return (
    <div>
      <h1>File Content</h1>
      <pre>{content}</pre>
    </div>
  );
}

Isomorphic Design

Call functions identically on client and server. IRPC abstracts network boundaries so you can focus on logic.

🚀

Zero Boilerplate

No REST endpoints, no GraphQL schemas, no complex serialization. Just write functions and call them.

🔌

Transport Agnostic

Switch between HTTP, WebSockets, and other transports without changing a single line of your business logic.

🧠

Reduced Cognitive Load

A single mental model for local and remote functions. No more context switching between your business logic and the transport domain.

🔒

End-to-End Type Safety

Compile-time validation from client to server, with IDE support for cross-boundary refactoring and self-documenting APIs.

⚡️

Optimized Performance

Intelligent batching, connection reuse, and tree-shakable imports for optimal network efficiency and minimal bundle size.