New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nanostores

Package Overview
Dependencies
Maintainers
0
Versions
51
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

  • 0.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
146K
increased by4.13%
Maintainers
0
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

FAQs

Package last updated on 03 Aug 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc