For complete details, see the official migration guide
Major Changes Overview
v3 includes several breaking changes designed to improve the developer experience:- Rewritten types: Much better TypeScript experience
- New synced system: Improved sync/persist with new plugins
- Simplified computeds: Now just functions
- Updated hooks: Better reactive behavior
- Removed features: Old persist system, some deprecated APIs
Breaking Changes
1. Types Rewritten from Scratch
The type system has been completely rewritten for better inference and stricter checking:The new types should “just work” for most use cases. If you encounter type errors, they’re likely catching real issues.
2. Computed and Proxy Are Now Just Functions
In v2, you usedcomputed() and proxy() helpers. In v3, just use functions:
3. New Synced System
The old persist system has been replaced with a newsynced system:
Switch to synced
Use the new
synced function with appropriate sync plugins:syncedKeelfor KeelsyncedSupabasefor SupabasesyncedFetchfor fetch APIsyncedQueryfor TanStack Query
4. useObservable with Functions is Reactive
In v2,useObservable with a function parameter was just for initialization. In v3, it’s reactive like useComputed:
5. Computeds Only Re-compute When Observed
Computeds are now lazy and only re-compute when something is listening:This improves performance by avoiding unnecessary computations. If you had computeds with side effects, you’ll need to explicitly observe them.
6. set() and toggle() Return Void
These methods no longer return the observable for chaining:7. onSet Renamed to onAfterSet
For clarity about when the listener fires:8. Removed Features
Several features have been removed:lockObservable
lockObservable
The
lockObservable function has been removed because the new computed system doesn’t support modifying types to be readonly.After batch concept
After batch concept
The concept of “after batch” has been removed as it was unreliable with recursive batches.
Old persist system
Old persist system
All old persist functions have been removed:
persistObservableusePersistedObservableconfigureObservablePersistence
synced system instead.9. Renamed Functions
Some functions have been renamed for clarity:New Features in v3
Improved Sync Plugins
v3 introduces powerful new sync plugins:Better TypeScript Support
Types are now much more accurate and helpful:Migration Steps
Fix TypeScript errors
Run TypeScript and fix any new errors. Most will be legitimate issues the new types caught:
Update useObservable
Add
.peek() to any observable accesses in useObservable functions if you want them non-reactive:Common Migration Issues
Type errors with observables
Type errors with observables
The new type system is stricter. Make sure you’re:
- Calling
.get()when you need the value - Not mixing Observable and plain types
- Using proper nullable types (
T | undefined | null)
Computeds not updating
Computeds not updating
In v3, computeds only re-compute when observed. Make sure something is actually listening:
Persistence not working
Persistence not working
The old persist system is completely removed. You must migrate to the new synced system:
useObservable behaving differently
useObservable behaving differently
Functions in
useObservable are now reactive. Use .peek() for non-reactive access:Getting Help
If you encounter issues during migration:- Check the official migration guide
- Review the CHANGELOG
- Ask in the Discord community
- Open an issue on GitHub
Summary
Migration Checklist:
- ✓ Update to latest version
- ✓ Fix TypeScript errors
- ✓ Replace
computed()withobservable(() => ...) - ✓ Migrate from old persist to new synced system
- ✓ Add
.peek()to non-reactiveuseObservablefunctions - ✓ Remove method chaining after
.set()/.toggle() - ✓ Rename
onSettoonAfterSet - ✓ Update renamed functions
- ✓ Test thoroughly
Next Steps
- Learn about Performance optimization
- Explore React Native setup
- Master TypeScript usage