PACKAGE · STATE MANAGEMENT

nanostores

A tiny (340 bytes) state manager for React/Preact/Vue/Svelte with many atomic tree-shakable stores

WEEKLY DOWNLOADS 6.1M
STARS 7.5K
FORKS 159
OPEN ISSUES 21
GZIP SIZE 2.2 kB
UNPACKED SIZE 51.0 kB
DEPENDENCIES 1
LAST UPDATED 5mo ago
DOWNLOAD TRENDS

nanostores downloads — last 12 months

Download trends for nanostores1 download series from Aug 2025 to Jul 2026. Use left and right arrow keys to inspect monthly values.06.6M13.3M19.9M26.5MAug 2025NovFebMayJul 2026
nanostores
ABOUT NANOSTORES

Nanostores offers a highly efficient and minimalistic approach to state management, designed to solve the common problem of managing application-wide or component-scoped dynamic data without introducing significant overhead. It distinguishes itself with an exceptionally small footprint, weighing in at just 340 bytes, which significantly benefits applications focused on performance and fast loading times.

The core philosophy behind Nanostores is atomicity and extreme tree-shakability. It provides a set of primitive store types that can be composed and derived, enabling developers to build complex state structures from simple, independently manageable pieces. This design makes it suitable for a wide range of frontend developers, particularly those working with modern JavaScript frameworks aiming for optimized bundle sizes.

Key API patterns revolve around creating and subscribing to stores. Developers interact with stores using fundamental operations like `atom()` for simple state, `map()` for object-like structures, and `computed()` for derived state. The reactive nature is handled via listeners or framework-specific integrations, ensuring UI updates efficiently when state changes.

Nanostores is built with broad framework compatibility in mind, offering explicit adapters for React, Preact, Vue, and Svelte. This allows for seamless integration into existing projects using these popular UI libraries, providing a unified state management solution across different frontend ecosystems.

With a bundle size of only 2.2 kB (gzipped) and a 340-byte core, Nanostores excels in performance-critical applications. Its size and design contribute to faster initial loads and reduced runtime overhead. The package has maintained a consistent level of development, evidenced by its 7.5K GitHub stars and 5.2M weekly downloads, indicating a mature and actively used solution.

However, Nanostores' simplicity means it doesn't include built-in solutions for more complex state management concerns such as asynchronous operation handling or sophisticated middleware patterns found in larger libraries. Developers needing these functionalities would need to implement them externally or opt for a different solution.

WHEN TO USE
  • When optimizing for the smallest possible bundle size in a React, Preact, Vue, or Svelte application.
  • For managing simple atomic states that are frequently updated and need efficient reactivity.
  • When building derived state logic using the `computed()` API for complex UI states based on multiple sources.
  • For integrating a performant state solution into server-rendered applications where initial load performance is critical.
  • When you need granular control over state updates and want to avoid the boilerplate of larger state management libraries.
  • For projects where leveraging tree-shakable code is a primary development goal.
WHEN NOT TO USE
  • If your application requires built-in solutions for complex asynchronous request management as part of the state library.
  • When preferring a monolithic state management library that offers extensive middleware and devtools out-of-the-box.
  • If you are working with a framework that Nanostores does not provide explicit integration for, requiring significant custom setup.
  • For scenarios where explicit support for complex immutability patterns or time-travel debugging is a mandatory requirement for the state solution.
  • If you favor a state management approach that abstracts away direct store manipulation in favor of action-based updates for all state changes.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 8
nanostores vs redux ★ 61.5K · 33.5M/wk nanostores vs recoil ★ 19.4K · 407.9K/wk nanostores vs jotai ★ 21.2K · 4.7M/wk nanostores vs mobx ★ 28.2K · 3.2M/wk nanostores vs @reduxjs/toolkit ★ 11.2K · 21.6M/wk nanostores vs xstate ★ 30.0K · 4.3M/wk nanostores vs valtio ★ 10.2K · 1.6M/wk nanostores vs zustand ★ 58.5K · 41.3M/wk