title: Node.js & Bun
icon: node-js
The Rivet JavaScript client allows you to connect to and interact with actors from browser and Node.js applications.
Quickstart
Create a new Node.js project
Create a new Node.js project with TypeScript support:
Install Rivet packages
Install the Rivet client and Node.js platform packages:
Define your actor schema and implementation. Create a new file for your actor:
// actors/counter.ts
import { Actor } from '@rivetkit/actor';
export interface CounterState {
count: number;
}
export class CounterActor extends Actor<CounterState> {
getInitialState() {
return { count: 0 };
}
increment() {
this.setState({ count: this.state.count + 1 });
}
decrement() {
this.setState({ count: this.state.count - 1 });
}
}Create your client
Create a file src/client.ts in your project to connect to your actor:
Start the Rivet development studio to test your actors locally:
npx rivetkit devThis will start the local development server and open the Rivet Studio in your browser where you can interact with your actors.
Run your client
In a separate terminal, run your client code:
You should see output like:
Run it again to see the state update.
Deploy your actors to production:
npx rivetkit deployThis will build and deploy your actors to the Rivet cloud platform. Make sure you're logged in with rivetkit login.
Next Steps
For more information on communicating with actors, including event handling and RPC calls, see Communicating with Actors.