nanostores

A tiny (~1kb), framework-agnostic state manager built for the era of many small stores.

nanostores

General JS

A tiny (~1kb), framework-agnostic state manager built for the era of many small stores.

Fit

Bundle (gzip)

2.2 kB

4.9 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

Sharing state across React, Vue, Svelte, and vanilla islands — common in Astro and micro-frontend setups — usually means a different store for each framework and a lot of bundle weight for something conceptually simple.

What It Does

Nanostores provides atoms and maps in around a kilobase, with official bindings for React, Preact, Vue, Svelte, Solid, and vanilla JS. Stores are tree-shakeable and lazy, so unused state costs nothing, making it ideal for multi-framework and edge-rendered apps.

Installation

bash
npm install nanostores

Usage Example

js
import { atom } from 'nanostores';
import { useStore } from '@nanostores/react';

export const $counter = atom(0);

export function Counter() {
  const count = useStore($counter);
  return <button onClick={() => $counter.set($counter.get() + 1)}>{count}</button>;
}

Related packages