What is Legend-State?
Legend-State is a super fast all-in-one state and sync library that lets you write less code to make faster apps. There is no boilerplate and no contexts, actions, reducers, dispatchers, sagas, thunks, or epics. It doesn’t modify your data at all - just callget() to get the raw data and set() to change it.
Key Features
Easy to Use
No boilerplate, contexts, or complex patterns. Just
get() and set() for state management.Blazing Fast
The fastest React state library. Beats every other library on benchmarks and even vanilla JS on some tests.
Fine-Grained Reactivity
Components re-render only when the specific data they use changes, making your apps lightning fast.
Powerful Sync & Persistence
Built-in local-first sync with plugins for Supabase, Keel, TanStack Query, and more.
Type-Safe
Fully typed with TypeScript for the best developer experience.
Tiny Bundle Size
Only 4kb minified and gzipped - massive savings in bundle size.
Why Legend-State?
Super Easy to Use
There is no boilerplate and there are no contexts, actions, reducers, dispatchers, sagas, thunks, or epics. It doesn’t modify your data at all, and you can just callget() to get the raw data and set() to change it.
In React components you can use the observer HOC to automatically re-render whenever observables change, or use hooks like useSelector for more control.
The Fastest React State Library
Legend-State beats every other state library on just about every metric and is so optimized for arrays that it even beats vanilla JS on the “swap” and “replace all rows” benchmarks. At only 4kb and with the massive reduction in boilerplate code, you’ll have big savings in file size too.Fine-Grained Reactivity for Minimal Renders
Legend-State lets you make your renders super fine-grained, so your apps will be much faster because React has to do less work. The best way to be fast is to render less, less often.Powerful Sync and Persistence
Legend-State includes a powerful sync and persistence system. It easily enables local-first apps by optimistically applying all changes locally first, retrying changes even after restart until they eventually sync, and syncing minimal diffs. Local persistence plugins for the browser and React Native are included, with sync plugins for Keel, Supabase, TanStack Query, andfetch.
Get Started
Installation
Install Legend-State with your favorite package manager.
Quickstart
Build your first app with Legend-State in minutes.
Core Concepts
Learn the fundamentals of observables and reactivity.
React Integration
Integrate Legend-State with React using hooks and reactive components.
Community
GitHub
Star us on GitHub and contribute to the project.
Discord
Join our community on Discord to get help and discuss Legend-State.