Skip to content

Introduction

Nano Kit is a lightweight, modular, and performant state management ecosystem for building modern web applications. Each library is designed to be small and tree-shakeable, while still offering rich DX and useful features.

import { signal, mountable, onMount, computed, effect } from '@nano_kit/store'
/* Create independent mountable atomic store */
const $count = mountable(signal(1))
/* Mountable: Run logic only when store has listeners */
onMount($count, () => {
console.log('Mounted: Store is active')
/* e.g., open websocket, start timer, etc. */
return () => {
console.log('Unmounted: Store is idle')
/* e.g., close websocket, stop timer */
}
})
/* Derive state (computed values are lazy & cached) */
const $double = computed(() => $count() * 2)
/* React to changes (triggers onMount) */
const unsub = effect(() => {
console.log(`Count: ${$count()}, Double: ${$double()}`)
})
/* Update triggers granular propagation */
$count(2)
/* Cleanup: removes listener and triggers onMount destructor */
unsub()
PackageDescription
@nano_kit/storeSignals-based state management library.
@nano_kit/queryData fetching and caching library, built on @nano_kit/store.
@nano_kit/routerRouting library, built on @nano_kit/store.
@nano_kit/ssrBase package for building framework-specific SSR adapters.
@nano_kit/devtoolsIn-page DevTools panel for @nano_kit/store.
@nano_kit/testingTesting tools for stories, tests and demos.
AdapterDescription
@nano_kit/reactReact integration for @nano_kit/store.
@nano_kit/react-routerReact integration for @nano_kit/router.
@nano_kit/react-ssrReact SSR adapter for @nano_kit/ssr.
@nano_kit/preactPreact integration for @nano_kit/store.
@nano_kit/preact-routerPreact integration for @nano_kit/router.
@nano_kit/preact-ssrPreact SSR adapter for @nano_kit/ssr.
@nano_kit/svelteSvelte integration for @nano_kit/store.
@nano_kit/svelte-routerSvelte integration for @nano_kit/router.
@nano_kit/svelte-ssrSvelte SSR adapter for @nano_kit/ssr.
@nano_kit/svelte-kitSvelteKit integration for stores, router, and SSR.
@nano_kit/next-routerNext.js integration for @nano_kit/router.

Nano Kit is built on the philosophy of Nano Stores and extends its core ideas:

  • Atomicity: Use independent, atomic stores for granular updates.
  • Mountable stores: Initialize resources only when the store is in use (on first listener) and clean up automatically.
  • Shift logic out of components: Move business logic to the store level.
  • Minimal footprint: Maintain a tiny core size that is fully tree-shakeable.

However, Nano Stores has some limitations:

  • Performance overhead
  • Suboptimal Developer Experience (DX)
  • Issues with SSR support

Nano Kit aims to fix these issues while keeping the same principles.

Adopting an ecosystem-first architecture provides a much smoother experience for developers than a stack of independent libraries. Because every part of the ecosystem is built on the same foundation, you get a consistent “feel” across the entire library. This shared core allows the tools to reuse internal logic, which drastically reduces your final bundle size.

Compare this to a standard setup like React Router + Redux + React Query. While these are great tools, they are effectively strangers to each other. They each have their own way of doing things and their own internal weight, often leading to duplicated code. Consequently, developers are forced to manually synchronize state and data between these independent tools inside the UI components, often resulting in bloated “glue code”.

Nano Kit takes a different approach. Because the router, data fetching, and state management layer are engineered to work together from day one, they integrate deeply at the store level. This removes the need for messy “glue code” in your components and keeps your application logic clean, unified, and efficient. It makes the store layer portable and independent, allowing you to easily swap the UI layer.

import { browserNavigation, searchParams, searchParam } from '@nano_kit/router'
import { client, queryKey } from '@nano_kit/query'
import { effect } from '@nano_kit/store'
import { useSignal } from '@nano_kit/react'
/* Router */
const [$location, navigation] = browserNavigation({ /* routes */ })
const $searchParams = searchParams($location)
const $page = searchParam($searchParams, 'page', v => (v ? Number(v) : 1))
/* Query */
const { query } = client()
const [
$episodes,
$episodesError,
$episodesLoading
] = query(queryKey('episodes'), [$page], async (page) => {
/* Fetcher automatically receives the current page */
return fetch(`/api/episodes?page=${page}`).then(r => r.json())
})
/* Logic is fully decoupled from UI components */
effect(() => {
console.log('Current page:', $page())
console.log('Episodes:', $episodes())
})
/* UI components remain pure and logic-free. Example (React): */
function MyComponent() {
const page = useSignal($page)
const episodes = useSignal($episodes)
/* ... */
}
/* Changing the URL updates $page signal and automatically triggers re-fetch */
navigation.push('/episodes?page=2')

To achieve high performance, Nano Kit uses the push-pull algorithm from alien-signals as the core of its reactivity system. A dedicated fork named “Agera” was created to support additional required features.

The benchmark results below show how @nano_kit/store (Agera) compares to other popular state management libraries.

LibraryLatency avg (ns)Latency med (ns)Throughput avg (ops/s)Throughput med (ops/s)Samples
alien-signals300.36
± 0.42%
290.00
± 0.00
3463918
± 0.01%
3448276
± 0
3329289
@nano_kit/store322.67
± 1.53%
300.00
± 0.00
3257518
± 0.01%
3333333
± 0
3099179
@preact/signals-core337.18
± 1.48%
310.00
± 0.00
3163533
± 0.01%
3225806
± 0
2965757
svelte/store420.22
± 1.75%
380.00
± 10.00
2571799
± 0.01%
2631579
± 64103
2379856
rxjs500.02
± 1.62%
430.00
± 10.00
2208408
± 0.02%
2325581
± 50505
1999907
zustand, subscribeWithSelector978.18
± 9.82%
530.00
± 10.00
1785767
± 0.03%
1886792
± 36284
1025340
nanostores1278.6
± 3.83%
990.00
± 20.00
955623
± 0.03%
1010101
± 20002
782092
mobx2682.5
± 2.55%
2310.0
± 30.00
419932
± 0.03%
432900
± 5456
372782
valtio5777.0
± 29.19%
3680.0
± 100.00
257516
± 0.07%
271739
± 7590
173967
jotai11425
± 9.54%
7720.0
± 160.00
120417
± 0.11%
129534
± 2727
87825
effector25789
± 9.66%
15940
± 590.50
59164
± 0.17%
62735
± 2366
38776
@reatom/core67429
± 12.44%
44810
± 3630.0
20913
± 0.33%
22316
± 1929
14842

Median of 11 rounds, each library measured in a fresh Node.js process in shuffled order. Run on AMD Ryzen 5 PRO 3400G with Node.js v26.10.0.

Comparison of bundle sizes for various implementations of the weather example:

StackRaw SizeGzipped Size
Nanoviews + Nano Kit28.11 kB10.77 kB
Nanoviews + Nano Kit + DI29.44 kB11.23 kB
React + Nano Stores206.71 kB65.53 kB
React + Nano Kit211.40 kB66.93 kB
React + Nano Kit + DI212.92 kB67.51 kB
React + Reatom228.10 kB72.57 kB
React + TanStack Query232.56 kB71.97 kB

Bundled with Vite 8. The Nanoviews implementations live in the Nanoviews repository.

Comparison of frontend bundle sizes for various SSR implementations of the rick-and-morty example:

StackRaw SizeGzipped SizeRaw Size
/characters page
React + Nano Kit SSR236.62 kB76.29 kB223.73 kB
React + TanStack Start374.87 kB116.02 kB364.48 kB
Next.js Pages Router + Nano Kit509.81 kB161.18 kB368.02 kB
Next.js App Router + Nano Kit947.61 kB292.32 kB471.57 kB

Bundled with Vite 8 / Next.js 16