Count: {count}
@@ -150,7 +150,7 @@ The React integration leverages React's hooks system to provide an idiomatic way The main function that creates React hooks for interacting with RivetKit. It takes a client instance and returns hook functions. ```tsx -const { useActor, useActorEvent } = createReactRivetKit(client); +const { useWorker, useWorkerEvent } = createReactRivetKit(client); ``` #### Parameters @@ -160,46 +160,46 @@ const { useActor, useActorEvent } = createReactRivetKit(client); #### Returns An object containing React hooks: -- `useActor`: Hook for connecting to actors -- `useActorEvent`: Hook for subscribing to actor events +- `useWorker`: Hook for connecting to workers +- `useWorkerEvent`: Hook for subscribing to worker events -### `useActor` +### `useWorker` -Hook that connects to an actor, creating it if necessary. It manages the actor connection and returns the actor handle. +Hook that connects to a worker, creating it if necessary. It manages the worker connection and returns the worker handle. ```tsx -const [{ actor, error, isLoading, state }] = useActor(actorName, options); +const [{ worker, error, isLoading, state }] = useWorker(workerName, options); ``` #### Parameters -- `actorName`: The name of the actor to connect to (string). -- `options`: Optional connection options (same options as `client.actorName.get()`). - - `id`: String identifier for the actor instance. - - `tags`: Key-value pairs for actor identification. +- `workerName`: The name of the worker to connect to (string). +- `options`: Optional connection options (same options as `client.workerName.get()`). + - `id`: String identifier for the worker instance. + - `tags`: Key-value pairs for worker identification. - `params`: Parameters to pass during connection. - - `noCreate`: Boolean to prevent actor creation if it doesn't exist. + - `noCreate`: Boolean to prevent worker creation if it doesn't exist. #### Returns Returns an array with a single object containing: -- `actor`: The actor handle if connected, or `undefined` if still connecting. +- `worker`: The worker handle if connected, or `undefined` if still connecting. - `error`: Any error that occurred during connection. - `isLoading`: Boolean indicating if the connection is in progress. - `state`: String representing the internal connection state ("init", "creating", "created", or "error"). -### `useActorEvent` +### `useWorkerEvent` -Hook that subscribes to events from an actor. +Hook that subscribes to events from a worker. ```tsx -useActorEvent({ actor, event }, cb); +useWorkerEvent({ worker, event }, cb); ``` #### Parameters - `opts`: Object containing: - - `actor`: The actor handle from `useActor`, or undefined. + - `worker`: The worker handle from `useWorker`, or undefined. - `event`: The name of the event to subscribe to. - `cb`: Function called when the event is fired. The arguments passed to this function depend on the event type. @@ -212,27 +212,27 @@ This hook doesn't return a value. The subscription is automatically managed by t ### Simple Counter ```tsx -import { createClient } from "@rivetkit/actor/client"; +import { createClient } from "rivetkit/client"; import { createReactRivetKit } from "@rivetkit/react"; -import type { App } from "../actors/app"; +import type { App } from "../workers/app"; import { useState } from "react"; // Connect to RivetKit const client = createClientCount: {count}
-Distributed workflow engine for durable business processes.
-Replaces Temporal, AWS Step Functions, or LangGraph
+Stateful worker model for building reliable, scalable, and maintainable backend services.
+Replaces Durable Objects, Orelans, or Akka
Framework for building, deploying, and orchestrating AI agents in production.
-Replaces LangChain, LlamaIndex, or AutoGen
+Distributed workflow engine for durable business processes.
+Replaces Cloudflare Workflows, Temporal, or AWS Step Functions
Stateful actor model for building reliable, scalable, and maintainable backend services.
-Replaces Durable Objects, AWS EventBridge, or Orleans
+Framework for building, deploying, and orchestrating AI agents in production.
+Replaces LangChain, LlamaIndex, or AutoGen
Stateful serverless is very similar to actors: it's essentially actors with persistence, and usually doesn't have as rigid constraints on message handling. This makes it more flexible while maintaining the core benefits of the actor model.
+Stateful serverless is very similar to workers: it's essentially workers with persistence, and usually doesn't have as rigid constraints on message handling. This makes it more flexible while maintaining the core benefits of the worker model.
Yes, but only as much as storing data in a single database row does. We're working on building out read replicas to allow you to perform read-only actions on actors.
+Yes, but only as much as storing data in a single database row does. We're working on building out read replicas to allow you to perform read-only actions on workers.
- Startups increasingly build on stateful serverless to ship faster, achieve better performance, and outscale databases like Postgres. The actor model – closely related to stateful serverless – has an established history in frameworks like Elixir, Orleans, and Akka, though these typically involve steep learning curves and complex infrastructure. Cloudflare demonstrates the power of this approach, having built their entire infrastructure – including R2, Workflows, and Queues – on their stateful serverless engine called Durable Objects. + Startups increasingly build on stateful serverless to ship faster, achieve better performance, and outscale databases like Postgres. The worker model – closely related to stateful serverless – has an established history in frameworks like Elixir, Orleans, and Akka, though these typically involve steep learning curves and complex infrastructure. Cloudflare demonstrates the power of this approach, having built their entire infrastructure – including R2, Workflows, and Queues – on their stateful serverless engine called Durable Objects.
With years of experience in gaming infrastructure, we've seen firsthand how the stateful serverless model excels. After building numerous systems like matchmaking, chat, presence, and social networks using stateful serverless, we're convinced it's hands down the best way to build applications. However, the ecosystem lacks accessibility and resources. diff --git a/docs/snippets/landing-snippets.mdx b/docs/snippets/landing-snippets.mdx index 9caddc25b..6de6fe579 100644 --- a/docs/snippets/landing-snippets.mdx +++ b/docs/snippets/landing-snippets.mdx @@ -102,7 +102,7 @@ import RateReact from "/snippets/examples/rate-react.mdx";