rivetkit-client-react_skill

This skill helps React developers connect to Rivet Actors using @rivetkit/react, create hooks with createRivetKit, and manage realtime actor state.

6

GitHub Stars

2

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill rivet-dev/skills --skill rivetkit-client-react

  • index.json365 B
  • SKILL.md6.9 KB

Overview

This skill provides practical guidance for using RivetKit in React apps to connect to Rivet Actors with @rivetkit/react. It explains how to create hooks with createRivetKit, manage realtime actor state with useActor, and combine client calls for server or stateless use. Content focuses on concrete examples, connection parameters, event subscriptions, and error handling patterns.

How this skill works

createRivetKit builds typed React hooks wired to a Rivet client instance. useActor returns connection state, a live connection object for calling actor actions, and helpers for subscribing to actor events and lifecycle errors. For one-off or server calls, the plain JavaScript client (createClient) offers HTTP and WebSocket access and actor handle management (get/getOrCreate/getForId).

When to use it

  • Building interactive React components that need realtime actor state and actions.
  • Subscribing to actor events inside components (messages, broadcasts).
  • Making one-off or server-side actor calls with createClient (SSR, backend jobs).
  • Passing connection parameters like auth tokens per actor instance.
  • Managing actor lifecycle and handling connection errors in UI.

Best practices

  • Use createRivetKit at app root to provide typed hooks and environment config.
  • Identify actors with array keys (compound keys) instead of interpolated strings to avoid key injection.
  • Prefer useActor for realtime UI and createClient for stateless or backend calls.
  • Pass auth or custom params via the params option on useActor instead of embedding credentials in the UI.
  • Handle ActorError explicitly to inspect error.code and metadata for user-friendly messages.

Example use cases

  • Realtime counter button that calls connection.increment(1) after useActor connects.
  • Chat room component subscribing to "message" events via chat.useEvent to append messages to state.
  • Server-side job that uses createClient to getOrCreate an actor and call actions without a WebSocket.
  • Protected room connection that supplies an authToken in params when calling useActor.
  • Fetching actor history with handle.fetch("history") and low-level WebSocket streaming with handle.webSocket("stream").

FAQ

createRivetKit reads RIVET_ENDPOINT, RIVET_NAMESPACE, and RIVET_TOKEN from env or you can pass an endpoint option. URL auth syntax (https://namespace:token@api.rivet.dev) is supported.

When should I use useActor vs createClient?

useActor is for lifecycle-managed realtime connections inside React components. createClient is for stateless or backend/SSR calls where you need raw HTTP/WebSocket or handle resolution.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
rivetkit-client-react skill by rivet-dev/skills | VeilStrat