You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

nanostores

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanostores

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

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
349K
4.96%
Maintainers
1
Weekly downloads
 
Created

What is nanostores?

Nanostores is a tiny state manager for React, Preact, Vue, Svelte, and vanilla JavaScript. It is designed to be small, fast, and efficient, making it suitable for both small and large applications. Nanostores provides a simple API for creating and managing reactive stores.

What are nanostores's main functionalities?

Creating a Store

Nanostores allows you to create a simple store using the `atom` function. This store can hold any type of data, and you can initialize it with a default value. In this example, a counter store is created with an initial value of 0.

import { atom } from 'nanostores';

const counter = atom(0);

Subscribing to a Store

You can subscribe to changes in a store using the `subscribe` method. This allows you to react to changes in the store's value. In this example, a subscription is set up to log the counter's value whenever it changes.

import { atom } from 'nanostores';

const counter = atom(0);

counter.subscribe(value => {
  console.log('Counter value:', value);
});

Updating a Store

Nanostores provides a `set` method to update the value of a store. You can also use the `get` method to retrieve the current value of the store. In this example, the counter's value is incremented by 1.

import { atom } from 'nanostores';

const counter = atom(0);

counter.set(counter.get() + 1);

Other packages similar to nanostores

Keywords

store

FAQs

Package last updated on 10 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.