Back to Rivet

Hello World

examples/hello-world-render/README.md

2.3.22.4 KB
Original Source

Note: This is the Render-optimized version of the hello-world example. It adds a production HTTP server, Vite build, and a render.yaml Blueprint for deploying to Render.

Hello World

A minimal example demonstrating RivetKit with a real-time counter shared across multiple clients, deployed on Render with Rivet Cloud.

Features

  • Actor state management: Persistent counter state managed by Rivet Actors
  • Real-time updates: Counter values synchronized across all connected clients via events
  • Multiple actor instances: Each counter ID creates a separate actor instance
  • React integration: Uses @rivetkit/react for seamless React hooks integration

Implementation

This example demonstrates the core RivetKit concepts with a simple counter:

  • Actor Definition (src/rivet/counter.ts): Counter actor with persistent state and broadcast events
  • Server Setup (src/http/server.ts): Production HTTP server that serves the built client and forwards /api/rivet/* to the registry handler
  • React Frontend (frontend/app/App.tsx): Counter component using useActor hook and event subscriptions

Deploy on Render

  1. Set Root Directory to examples/hello-world-render if deploying from the monorepo.
  2. Add the following environment variables in your Render service:
VariableDescription
RIVET_ENDPOINTBackend endpoint URL from your Rivet Cloud project
RIVET_PUBLIC_ENDPOINTPublic endpoint URL from your Rivet Cloud project
  1. In the Rivet dashboard, point Connect your backend at your service's HTTPS URL.

RIVET_ENVOY_VERSION is automatically derived from Render's RENDER_GIT_COMMIT — no manual bump needed per deploy. Set it explicitly to override.

Resources

License

MIT