Skip to content

feat(rivetkit): add support for tanstack query#4419

Open
jog1t wants to merge 1 commit intomainfrom
feat/react-query
Open

feat(rivetkit): add support for tanstack query#4419
jog1t wants to merge 1 commit intomainfrom
feat/react-query

Conversation

@jog1t
Copy link
Contributor

@jog1t jog1t commented Mar 13, 2026

This pull request introduces a new example project demonstrating how to integrate Rivet Actors with TanStack React Query in a React application. The example provides a full-stack setup, including backend actor definitions, frontend React components, build configuration, and documentation. It also updates workspace and lockfile dependencies to support the new example.

New Example: React Query Integration with Rivet Actors

  • Example Project Structure and Features

    • Adds a new examples/react-query directory with a complete example of integrating Rivet Actors and TanStack React Query, including backend actor logic, frontend React UI, and real-time state synchronization. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Frontend Implementation

    • Implements a React frontend using @rivetkit/react and @tanstack/react-query, with a sample App.tsx that connects to a backend actor, subscribes to events, and mirrors actor state into the React Query cache for live UI updates. [1] [2] [3]
  • Backend Actor and API

    • Defines a simple counter actor in src/actors.ts and exposes it via an HTTP API using Hono in src/server.ts. [1] [2]

Documentation and Configuration

  • Documentation and Setup

    • Provides a detailed README.md with setup instructions, feature overview, and resource links for the new example. Adds a tsconfig.json and package.json with all necessary dependencies and scripts for building and running the project. [1] [2] [3]
  • Build and Workspace Integration

    • Adds Vite and Turbo configuration for development and builds, and integrates the example into the monorepo workspace with updates to pnpm-lock.yaml and workspace dependency overrides. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

@railway-app
Copy link

railway-app bot commented Mar 13, 2026

🚅 Deployed to the rivet-pr-4419 environment in rivet-frontend

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web Mar 13, 2026 at 9:13 pm
frontend-inspector 😴 Sleeping (View Logs) Web Mar 13, 2026 at 9:13 pm
frontend-cloud 😴 Sleeping (View Logs) Web Mar 13, 2026 at 9:12 pm
mcp-hub ✅ Success (View Logs) Web Mar 13, 2026 at 9:00 pm
ladle ❌ Build Failed (View Logs) Web Mar 13, 2026 at 8:59 pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4419

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4419

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4419

@rivetkit/query-core

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/query-core@4419

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4419

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4419

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4419

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4419

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4419

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4419

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4419

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4419

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4419

commit: 16feaa1

@claude
Copy link

claude bot commented Mar 13, 2026

---\n## PR Review: feat(rivetkit): add support for tanstack query\n\nGood addition overall — the architecture of extracting shared query-sync logic into a dedicated @rivetkit/query-core package is clean and the example demonstrates the integration well. A few issues need attention before merge.\n\n---\n\n### Critical: Packaging Bugs\n\n**@rivetkit/react is missing required dependencies**\n\nrivetkit-typescript/packages/react/package.json imports from both @rivetkit/query-core and @tanstack/react-query but neither is listed in dependencies or peerDependencies. When published to npm, installing @rivetkit/react will not pull these packages in and end-user builds will fail at runtime.\n\n@rivetkit/query-core should be a regular dependency (or bundled), and @tanstack/react-query should be an optional peer dependency (since the query integration is opt-in via the queryClient argument).\n\n---\n\n### Important: Stale Closure in useActorQuery\n\nrivetkit-typescript/packages/react/src/mod.ts — the syncActorToQueryClient call inside useActorQuery uses actorOpts as an effect dependency:\n\n\nuseEffect(() => {\n const { unsubscribe } = syncActorToQueryClient({\n actorOpts, // new object reference on every render\n ...\n });\n return unsubscribe;\n}, [actorOpts, localQueryClient, resolvedQueryKeyFn]);\n\n\nWhen callers inline the options object, actorOpts is a new reference every render, so the teardown/resubscribe cycle fires on every render. The same key-serialization approach already used in useActor (serialize to a stable string and use that as the dep) should be applied here too.\n\n---\n\n### Important: queryFn Returning Null Masked as the Type\n\nIn both useActorQuery and the example App.tsx:\n\n\nqueryFn: () => Promise.resolve(null as unknown as ActorConnState<...>),\nenabled: false,\n\n\nIf a consumer ever calls query.refetch() — manually, via DevTools, or because of default window-focus refetch behavior — this silently overwrites the entire actor state cache entry with null. Consider throwing a descriptive error instead.\n\n---\n\n### Example Issues\n\nMissing Vercel example — CLAUDE.md requires a Vercel equivalent for every new example, or skipVercel: true in a template field of the example package.json. Neither is present here.\n\nStale copy-paste in index.html — the page title reads Hono React Counter instead of something like React Query + Rivet Actors.\n\nREADME uses npm install instead of pnpm — the project-wide convention is pnpm.\n\nREADME uses relative doc links — links like /docs/platforms/react only resolve correctly on the docs site. Use absolute URLs in the example README, consistent with other examples in the repo.\n\n**@tanstack/react-query-devtools in dependencies** — this is a dev/debug tool and belongs in devDependencies in the example package.json.\n\n---\n\n### Minor / Nits\n\n**sideEffects field** — both @rivetkit/query-core and @rivetkit/react package.json files list chunk files in sideEffects. Internal chunk files are generated artifacts, not public exports. Either omit the field entirely or set it to false if there are truly no side effects.\n\n**README.md missing from @rivetkit/react files array** — @rivetkit/query-core/package.json includes it but @rivetkit/react/package.json does not. Looks like an oversight.\n\n**useEvent hook factory** — calling useRef/useStore/useEffect inside the returned useEvent closure requires multiple Biome suppressions and is fragile for React Compiler compatibility. Worth a follow-up to refactor into a proper named hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant