TypeScript
Call your pyRPC server from any TypeScript environment with full type safety.
TypeScript Client
The @pyrpc/client package provides a lightweight, framework-agnostic runtime for calling your RPC procedures. Combined with generated Typed Contracts, it provides a first-class developer experience with zero boilerplate.
1. Install
npm install @pyrpc/client@pyrpc/client is a thin fetch-based runtime with no codegen or postinstall step. The TypeScript types come from the __pyrpc.ts file that pyrpc dev generates in your client project root, import type { Types } from "@pyrpc/types" resolves to it via a tsconfig path alias that pyrpc dev configures automatically (and via a bundler alias for Vite, SvelteKit, and Next.js Turbopack).
If you need to regenerate types later (e.g. after adding procedures), just save your .py file while pyrpc dev is running, or run the CLI directly:
pyrpc codegen http://localhost:8000 --client .2. Create the Client
Use the createClient<Types>() factory to initialize your typed client. Transport is configured with a link, the URL belongs to the link, not the client.
import { createClient, httpBatchLink } from "@pyrpc/client"
import type { Types } from "@pyrpc/types"
// Multiple operations share one HTTP request
export const client = createClient<Types>({
links: [
httpBatchLink({
url: "https://api.example.com",
}),
],
});3. Transport
The transport is configured with a link — see Links for the full reference (httpLink, httpBatchLink, options, and batching semantics).
4. Call Procedures
Procedures are available as async methods with full autocompletion and type validation.
// Inside a React component or Server Action
const user = await client.get_user({ id: 1 });
console.log(user.name); // Typed as string!Error Handling
The client throws PyRPCError for structured server-side errors. See Error Handling for the full guide.
import { PyRPCError } from "@pyrpc/client";
try {
const result = await client.add(10, 20);
} catch (e) {
if (e instanceof PyRPCError) {
console.error(`Error ${e.code}: ${e.message}`);
}
}Next Steps
- Links - HTTP Link and HTTP Batch Link
- Adapters - React, Next.js, Vue, and Svelte
- Vanilla Python Client

pyRPC