Documentation chapters

RPC Client

To use a registered controller of your server application, you need to instantiate a client, connect to it, and call actions. RPC controllers registered in Deepkit Framework are per default exposed via WebSockets.

To connect to it you should use the DeepkitClient class, which connects per default via WebSockets.

#!/usr/bin/env ts-node-script
import { DeepkitClient } from '@deepkit/rpc';
import { MyRPCInterface } from './my-rpc';

async function main() {
    const client = new DeepkitClient('ws://localhost:8080');
    const myRpcController = client.controller(MyRPCInterface);

    console.log(await myRpcController.helloWorld());



DeepkitClient tries to automatically use the global WebSocket object (for browser environments) or falls back to require the ws package (for node environments).

Connection is automatically established on the first action call. An error is thrown if connection can not be established or access is denied. You can manually connect using await client.connect().

More information about how to use the client and its features like error forwarding, streaming, upload/download tracking can be found in the full documentation about Deepkit RPC client.


You can also connect to a Deepkit RPC server via TCP (or any other transport protocol). @deepkit/rpc-tcp provides a connection adapter for TCP based on Node's net and a faster TCP implementation using turbo-tcp.

import { RpcClient } from '@deepkit/rpc';
import { TcpRpcClientAdapter } from '@deepkit/rpc-tcp';

const client = new RpcClient(new TcpRpcClientAdapter('localhost:8881'));

This requires to start the RPC server via a TCP implementation. RPC controllers in Deepkit Framework are not exposed via TCP, so you have to start a RPC TCP server manually. More information can be found in the full documentation about Deepkit RPC.

Made in Germany