nano-kit-store
Installation
SKILL.md
@nano_kit/store
@nano_kit/store is the signals core of Nano Kit: signals, computeds, effects, mountable stores with lifecycle hooks, dependency injection, async helpers and SSR hydration. Every other nano_kit package builds on it, and their skills point here instead of repeating it.
Reference
DOCS.md next to this file is the documentation of the released package as published on https://nano-kit.js.org, generated from the site sources. Read its relevant sections for exact signatures, options and examples before writing code. This skill adds only what the documentation leaves open: conventions, which tool to pick for which job, and pitfalls.
Mental model
- State is many small signals, not one object: one signal per independent piece of state. A cohesive entity (a user, a list) in one signal is fine.
- A store is a factory named
Something$: usually a function that creates signals and actions and returns them as an object, sometimes a class extendingInjectable$whose fields hold them. Stores get their dependencies throughinject()so that tests, SSR requests and platforms can swap them. - Resources (timers, sockets, requests) live in the lifecycle of a mountable signal, not in components:
onMountopens them when the first consumer appears and its cleanup closes them after the last one leaves. - Components only read signals and call actions. Derived values, validation and requests are computeds and actions in a store.