npx skills add ...
npx skills add rivet-dev/skills --skill rivetkit-client-swiftui
npx skills add rivet-dev/skills --skill rivetkit-client-swiftui
RivetKit SwiftUI client guidance. Use for SwiftUI apps that connect to Rivet Actors with RivetKitSwiftUI, @Actor, rivetKit view modifiers, and SwiftUI bindings.
Use this skill when building SwiftUI apps that connect to Rivet Actors with RivetKitSwiftUI.
RivetKit version: 2.3.7
do/catch unless absolutely needed.Add the Swift package dependency and import RivetKitSwiftUI:
RivetKitSwiftUI re-exports RivetKitClient and SwiftUI, so a single import covers both.
The @Actor property wrapper always uses get-or-create semantics and accepts:
name (required)key as String or [String] (required)params (optional connection parameters)createWithInput (optional creation input)createInRegion (optional creation hint)enabled (toggle connection lifecycle)Keys uniquely identify actor instances. Use compound keys (arrays) for hierarchical addressing:
Don't build keys with string interpolation like "org:\(userId)" when userId contains user data. Use arrays instead to prevent key injection attacks.
Call .rivetKit(endpoint:) or .rivetKit(client:) once at the root of your view tree:
When using .rivetKit(endpoint:), the client is created once and cached per endpoint. When using .rivetKit(client:), store the client as a property on App (not inside body) since SwiftUI can call body multiple times.
ClientConfig reads optional values from environment variables:
RIVET_NAMESPACE - Namespace (can also be in endpoint URL)RIVET_TOKEN - Authentication token (can also be in endpoint URL)RIVET_RUNNER - Runner name (defaults to "default")The endpoint is always required. There is no default endpoint.
Endpoints support URL auth syntax:
You can also pass the endpoint without auth and provide RIVET_NAMESPACE and RIVET_TOKEN separately. For serverless deployments, set the endpoint to your app's /api/rivet URL. See Endpoints for details.
@Actor(name, key:, params:, createWithInput:, createInRegion:, enabled:) - SwiftUI property wrapper for actor connections.rivetKit(endpoint:) - Configure client with an endpoint URL (creates cached client).rivetKit(client:) - Configure client with a custom instance.onActorEvent(actor, event) { ... } - Subscribe to actor events (supports 0–5 typed args).onActorError(actor) { error in ... } - Handle actor errorsactor.action(name, args..., as:) - Async action callactor.send(name, args...) - Fire-and-forget actionactor.events(name, as:) - AsyncStream of typed eventsactor.connStatus - Current connection statusactor.isConnected - Whether connectedactor.handle - Underlying ActorHandle (optional)actor.connection - Underlying ActorConnection (optional)actor.error - Most recent error (optional)ActorConnStatus - Connection status enum (.idle, .connecting, .connected, .disconnected, .disposed)ActorError - Typed actor errors with group, code, message, metadataIf you need more about Rivet Actors, registries, or server-side RivetKit, add the main skill:
Then use the rivetkit skill for backend guidance.