Client SDKs

JavaScript & TypeScript

This guide will walk you through setting up JavaScript/TypeScript client & connect to an actor.


Install client package

Install the Rivet actor package with:

npx jsr add @rivet-gg/actor-client

Connect to actor

Fetch the connection address using the Rivet CLI. Copy this value.

rivet get-address
Command Line

Use this code to create & connect to the actor. Replace /* CONNECTION ADDRESS */ with the value from the previous step.

import Client from "@rivet-gg/actor-client";
const client = new Client(/* CONNECTION ADDRESS */);

const counter = await client.get({ name: "counter" });  // Get or create a `counter` actor
const newCount = await counter.increment(5);  // Call the method `increment` on the `counter` actor
console.log("New count", newCount);
TypeScript

You can monitor the actor with:

Visit the Rivet Hub. Click on the actor with the green dot.


Next steps