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 🙏

© 2024 – Pkg Stats / Ryan Hefner

client-web-storage

v1.7.14

Published

Powerful Web Application Data Storage and State Management Solution.

Downloads

166

Readme

Client Web Storage

Powerful Web Application Data Storage and State Management Solution.

npm

  • Same simple API for IndexedDB, LocalStorage, WebSQL, and in-memory data storage;
  • Event driven and asynchronous;
  • Automatic data validation done at the store level - Guarantees that all data fields are of the right type and exists with configurable automatic defaults;
  • No actions or reducers setup needed - The easiest store to configure ever;
  • Easy setup for Client-Server data synchronization using interceptors;
  • NOT UI framework specific! Works with any UI Framework (React, Angular, VueJs, etc) - Take your storage setup with you when you migrate to a different framework and eliminate the need to learn a new state management solution for your app.
  • Easy to maintain and perform all data logic and fetching away from your components - Keep data concerns away from UI side of your app;
  • Highly and easily configurable;
  • Easy to tap into any store events to perform side effect logic;

Quick Example

// todo.store.ts

import {ClientStore} from "client-web-storage";

interface ToDo {
    name: string;
    description: string;
    complete: boolean;
}

// create a store providing the name and schema object
// with default values or javasctipt types
const todoStore = new ClientStore<ToDo>("todo", {
    $name: String,
    description: "No Description",
    complete: false
});

Works with any web library or framework. Here is an example using React.

// app.tsx

import {useClientStore} from "client-web-storage/helpers/use-client-store";
import {Todo} from "./stores/todo.store";
import FlatList from "flatlist-react";

const App = () => {
    const todos = useClientStore<Todo>("todo");
		
    if(todos.processing) {
        return <Spinner />
    }
    
    if(todos.error) {
        return <p className="error">{error.message}</p>
    }
	
    const handleCreatItem = async () => {
        await todos.createItem({
            // only name is required (marked with $), the store will auto fill the other fields with defaults
            name: "Go to Gym" 
        });
    }
    
    return (
        <>
            <button type="button" onClick={handleCreatItem}>create todo</button>
            <FlatList list={todos.items} renderItem={renderTodo}/>
        </>
    )
}

Installation

In Node Projects:

npm install client-web-storage
import {Schema, ClientStore} from "client-web-storage";

In the Browser

<!-- use the latest version -->
<script src="https://unpkg.com/client-web-storage/client-web-storage.min.js"></script>

<!-- use a specific version -->
<script src="https://unpkg.com/[email protected]/client-web-storage.min.js"></script>
<script>
  const {Schema, ClientStore} = window.CWS;
</script>

Documentation

Documentation

Application Examples

-- Check them All ---

API References