nanostores downloads · last 12 months
nanostores is a small state-management library for sharing application state across React, Preact, Vue, and Svelte interfaces. It addresses the problem of coordinating state between components without requiring an application-wide state container or a framework-specific state API.
Its design centers on many small, atomic stores that can be selected and composed independently. This approach is intended for developers who want shared state with a narrow footprint and prefer to add only the state units their application uses, rather than adopting a single, broad store structure.
The core pattern is to create a store, update its value, and subscribe to changes where the value is needed. Framework integrations provide ways to connect stores to UI components, including hooks for React and Preact; the package description also lists Vue and Svelte support. Atomic stores make it possible to keep unrelated state in separate units and subscribe to the specific state a component reads.
nanostores fits projects that use one of its supported frameworks and want shared state to remain usable across framework-facing code. Its store-based model can complement component-local state: keep transient UI details close to a component, and place state that must be shared in a store. The package is categorized as State Management and is available under the MIT license.
The listed package size is 55.0 kB unpacked, with a 2.4 kB gzip bundle size; its description characterizes it as a tiny 351-byte state manager, so size figures may refer to different measurements or scopes. Version 1.5.5 has 6.1M weekly downloads, 7.6K GitHub stars, 163 forks, and 23 open issues, with a last-updated date of 2026-10-15. These figures indicate substantial usage, but do not replace checking current compatibility and maintenance details for a particular project.
The package's atomic approach means developers must decide how to divide shared state into stores and how those stores relate; it does not, from the supplied information, promise a particular state-shape convention or workflow. Confirm the APIs and framework-specific setup for the installed version before integrating it, especially if an application depends on behavior or tooling not described here.
- When React components need to share state outside a single component tree, put the shared value in a nanostores store and connect components through the React integration.
- When using Preact and wanting shared state in small, independently subscribed units, use nanostores' Preact integration with atomic stores.
- When a Vue or Svelte interface needs to read shared state maintained in stores, use nanostores' listed framework integration rather than duplicating the value across components.
- When unrelated parts of an interface should subscribe to different pieces of state, split those values into atomic stores so consumers can target the state they use.
- When framework-facing code needs to share state through a common store layer, use nanostores stores as the boundary between that code and UI components.
- When limiting shipped state-management code is a priority, evaluate nanostores against its listed 2.4 kB gzip bundle size and select only the stores the application needs.
- If state is confined to one React or Preact component, use that framework's component-local state instead of creating a shared nanostores store.
- If the application requires a state-management framework with a specified workflow or guarantees not documented for nanostores, choose a tool whose documented capabilities match those requirements or verify them before adoption.
- If the team wants one centrally prescribed state shape rather than deciding how to divide state into atomic stores, use an approach that provides that convention.
- If the project uses a framework other than React, Preact, Vue, or Svelte, do not assume nanostores has a suitable integration; verify support or use a framework-compatible state mechanism.
- If the project needs a particular API or framework setup that is not confirmed for version 1.5.5, check the version's documentation and package contents before depending on it.
- If bundle-size decisions require a single, clearly defined measurement, reconcile the 351-byte description with the listed 2.4 kB gzip bundle size and 55.0 kB unpacked size before selecting nanostores.
CORRECTIONS
Spot wrong data here?Spot wrong data on this page?
A short note helps us fix it.A short note helps us fix it. We read every one; confirmed fixes ship in the next nightly build.
Anonymous · No account · No email back