nanostores
Nano Stores
A tiny state manager for React, React Native, Preact, Vue, Svelte, Solid, Lit, Angular, and vanilla JS. It uses many atomic stores and direct manipulation.
- Small. Between 351 and 844 bytes (minified and brotlied). Zero dependencies. It uses Size Limit to control size.
- Fast. With small atomic and derived stores, you do not need to call the selector function for all components on every store change.
- Tree Shakable. A chunk contains only stores used by components in the chunk.
- Designed to move logic from components to stores.
- Good TypeScript support.
// store/users.ts
import { atom } from 'nanostores'
export const $users = atom<User[]>([])
export function addUser(user: User) {
$users.set([...$users.get(), user])
}
// store/admins.ts
import { computed } from 'nanostores'
import { $users } from './users.ts'
export const $admins = computed($users, users => users.filter(i => i.isAdmin))
// components/admins.tsx
import { useStore } from '@nanostores/react'
import { $admins } from '../stores/admins.ts'
export const Admins = () => {
const admins = useStore($admins)
return (
<ul>
{admins.map(user => (
<UserItem user={user} />
))}
</ul>
)
}
Nano Stores is built by Evil Martians, an American design and engineering consultancy for developer tools, AI, and cybersecurity startups.
Docs
Read full docs here.
Related Packages
nanostores-cjs
A tiny (266 bytes) state manager for React/Preact/Vue/Svelte with many atomic tr...
11,648
7,630
@illuxiza/nanostores-immer
Immer integration for nanostores, providing immutable state updates with mutable...
9,732
11
@logux/state
A tiny (152 bytes) state manager for React/Preact/Vue/Svelte with many atomic tr...
35,227
7,630
@depup/nanostores
A tiny (351 bytes) state manager for React/Preact/Vue/Svelte with many atomic tr...
1,302
7,630
Version History
| Version | Released | License |
|---|---|---|
| 1.5.5 | MIT | |
| 1.5.4 | MIT | |
| 1.5.3 | MIT | |
| 1.5.2 | MIT | |
| 1.5.1 | MIT | |
| 1.5.0 | MIT | |
| 1.4.2 | MIT | |
| 1.4.1 | MIT | |
| 1.4.0 | MIT | |
| 1.3.0 | MIT | |
| 1.2.0 | MIT | |
| 1.1.1 | MIT | |
| 1.1.0 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT | |
| 0.11.4 | MIT | |
| 0.11.3 | MIT | |
| 0.11.2 | MIT | |
| 0.11.1 | MIT | |
| 0.11.0 | MIT | |
| 0.10.3 | MIT | |
| 0.10.2 | MIT | |
| 0.10.1 | MIT | |
| 0.10.0 | MIT | |
| 0.9.5 | MIT | |
| 0.9.4 | MIT | |
| 0.9.3 | MIT | |
| 0.9.2 | MIT | |
| 0.9.1 | MIT | |
| 0.9.0 | MIT |
Showing the latest 30 of 66. See every release on npm