clockworklabs / clockworklabs/SpacetimeDB
Tanstack Start: Optimistic update support for reducers
@clockwork-tien is already working on this.
Since Feb 27, 2026.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
Problem
There's no way to optimistically update the UI when calling a reducer. The UI only updates after the WebSocket round-trip — the reducer runs on the server, the subscription fires, and setQueryData updates the cache. This creates a noticeable delay between user action and UI response.
Since the TanStack integration already wraps React Query, it would be natural to support optimistic updates the way React Query mutations do — immediately update the cache with the expected result, then reconcile when the server confirms.
Something like:
const addReducer = useReducer(reducers.add, {
optimistic: (args, currentData) => {
return [...currentData, { name: args.name }];
},
});
or whatever your team prefers.
The SDK knows which tables a reducer modifies and already manages the React Query cache via setQueryData. It's in the best position to handle the optimistic update, rollback on error, and reconciliation when the real subscription update arrives.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.