npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

0x1-store

v0.0.4

Published

A lightweight, type-safe state management library for JavaScript and TypeScript applications.

Readme

0x1-store

A lightweight, type-safe state management library for JavaScript and TypeScript applications.

Features

  • 🔄 Simple API for state management
  • 🔒 Type-safe with full TypeScript support
  • 💾 Optional local storage persistence
  • 📢 Subscription-based updates
  • 🌐 Global store registry
  • 🪶 Tiny footprint with zero dependencies

Installation

# Using bun
bun add 0x1-store

# Using npm
npm install 0x1-store

# Using yarn
yarn add 0x1-store

Basic Usage

import { createStore } from '0x1-store';

// Create a store with initial state
const counterStore = createStore({ count: 0 });

// Get current state
console.log(counterStore.getState()); // { count: 0 }

// Update state with an object
counterStore.setState({ count: 1 });

// Update state with a function
counterStore.setState((prevState) => ({ 
  count: prevState.count + 1 
}));

// Subscribe to state changes
const unsubscribe = counterStore.subscribe((state) => {
  console.log('State updated:', state);
});

// Later, unsubscribe when needed
unsubscribe();

// Reset state to initial value
counterStore.reset();

Persistence

Enable localStorage persistence to keep state between page reloads:

import { createStore } from '0x1-store';

const userStore = createStore(
  { name: '', loggedIn: false },
  { 
    persist: true,
    storageKey: 'user-store' 
  }
);

// State will automatically be saved to localStorage
userStore.setState({ name: 'John', loggedIn: true });

// And loaded when the store is created again

Global Stores

Register and use stores across your application:

import { registerStore, useStore } from '0x1-store';

// In your store definition file
registerStore('theme', { dark: false });

// Anywhere else in your application
const themeStore = useStore('theme');
if (themeStore) {
  const { dark } = themeStore.getState();
  themeStore.setState({ dark: !dark });
}

API Reference

createStore<T>(initialState: T, options?: StoreOptions<T>): Store<T>

Creates a new store with the given initial state and options.

Store<T> Methods

  • getState(): T - Returns the current state
  • setState(updater: Partial<T> | ((state: T) => Partial<T>)): void - Updates the state
  • subscribe(callback: (state: T) => void): () => void - Subscribes to state changes, returns unsubscribe function
  • reset(): void - Resets the state to the initial value

StoreOptions<T>

  • initialState: T - The initial state of the store
  • persist?: boolean - Whether to persist the state to localStorage (default: false)
  • storageKey?: string - The key to use for localStorage (default: '0x1-store')

Global Store API

  • registerStore<T>(name: string, initialState: T, options?: StoreOptions<T>): Store<T> - Registers a global store
  • useStore<T>(name: string): Store<T> | null - Gets a registered store by name

License

MIT