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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-omni-store

v0.0.3

Published

A single React library for all browser storage needs: localStorage, sessionStorage, IndexedDB, and SQLite (WASM).

Readme

React Omni Store

A single React library to rule all your browser storage needs. react-omni-store provides a set of simple, powerful hooks to manage data in localStorage, sessionStorage, IndexedDB, and even a full SQLite database via WebAssembly.

Features

  • Unified API: Simple hooks for complex storage mechanisms.
  • Type-Safe: Written in TypeScript to ensure type safety.
  • Auto-Syncing: useStorage syncs across tabs automatically.
  • Persistent SQLite: useSQLiteDB leverages sql.js (WASM) and persists your database in IndexedDB.
  • Lightweight: Small footprint with easy-to-use hooks.

Installation

This project is set up as a monorepo. To use the library within this project, you can install dependencies at the root level:

npm i react-omni-store

Available Hooks

  1. useStorage
  2. useIndexedDB
  3. useSQLiteDB

useStorage

A hook to manage state in localStorage or sessionStorage. It works just like useState, but persists the value.

API: useStorage(key, initialValue, storageType)

  • key: The key to store the value under.
  • initialValue: The default value to use if none is found.
  • storageType: (Optional) 'localStorage' or 'sessionStorage'. Defaults to 'localStorage'.

Usage:

import { useStorage } from 'react-omni-store';

function MyComponent() {
  // Stored in localStorage
  const [name, setName] = useStorage('username', 'Guest');
  
  // Stored in sessionStorage
  const [sessionNotes, setSessionNotes] = useStorage('notes', '', 'sessionStorage');

  return (
    <div>
      <input 
        type="text" 
        value={name} 
        onChange={(e) => setName(e.target.value)}
      />
      <p>Hello, {name}!</p>
    </div>
  );
}

useIndexedDB

A simple key-value store hook that uses the browser's IndexedDB. It's great for storing larger amounts of data or more complex objects.

API: useIndexedDB(key, initialValue)

Usage:

import { useIndexedDB } from 'react-omni-store';

function Settings() {
  const [theme, setTheme] = useIndexedDB('theme', 'light');

  const toggleTheme = () => {
    setTheme(prevTheme => (prevTheme === 'light' ? 'dark' : 'light'));
  };

  return (
    <div>
      <p>Current theme: {theme}</p>
      <button onClick={toggleTheme}>Toggle Theme</button>
    </div>
  );
}

useSQLiteDB

A powerful hook that provides a full SQLite database in the browser, powered by sql.js (WASM). The database is automatically persisted to localStorage to survive page reloads.

Prerequisites: You must make the sql-wasm.wasm file available in your public folder.

API: useSQLiteDB()

Returns: An object with:

  • db: The database instance.
  • loading: A boolean indicating if the database is initializing.
  • error: Any error that occurred during initialization.
  • execute(sql, params): A function to execute SQL queries.
  • saveDatabase(): A function to manually trigger saving the DB to localStorage.

Usage:

import { useSQLiteDB } from 'react-omni-store';
import { useEffect, useState } from 'react';

function NotesManager() {
  const { loading, error, execute, saveDatabase } = useSQLiteDB();
  const [notes, setNotes] = useState([]);

  useEffect(() => {
    if (!loading) {
      execute("CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, content TEXT);");
      refreshNotes();
    }
  }, [loading]);

  const refreshNotes = () => {
    const result = execute("SELECT * FROM notes");
    if (result && result.length > 0) {
      const loadedNotes = result[0].values.map(row => ({ id: row[0], content: row[1] }));
      setNotes(loadedNotes);
    }
  };

  const addNote = async (content) => {
    execute("INSERT INTO notes (content) VALUES (?)", [content]);
    refreshNotes();
    await saveDatabase();
  };

  if (loading) return <p>Loading database...</p>;
  if (error) return <p>Error: {error.message}</p>;

  return (
    <div>
      {/* UI to add and display notes */}
    </div>
  );
}