Tag: react

  • Dawei

    Minimal, flexible state management for React.

    dawei is a tiny but powerful state management library for React. Inspired by Zustand and Recoil, it offers a simple API that works without context — with support for deeply nested values, subscriptions, and scoped stores. It’s built for projects that want fine-grained control without boilerplate.


    Features

    • Minimal API: No providers, no reducers, no boilerplate. Just a clean createStore() and store.use() pattern.
    • Deep State Access: Subscribe to and modify deeply nested keys like 'company.name' — even if they don’t exist yet.
    • Global Reactivity: All components stay in sync with the store automatically. No selectors or memo worries.
    • Direct Control: Update the store from anywhere in your app with store.set() or listen for changes with store.subscribe().

    Installation

    npm install dawei

    or

    yarn add dawei

    Usage Example

    import { createStore } from 'dawei';
    
    const formStore = createStore({});
    
    const Input = () => {
      const [name, setName] = formStore.use('name');
      const [email, setEmail] = formStore.use('email');
      const [companyName, setCompanyName] = formStore.use('company.name');
    
      return (
        
           setName(e.target.value)} />
           setEmail(e.target.value)} />
           setCompanyName(e.target.value)} />
        
      );
    };
    
    function randomBitOfApi() {
      formStore.set({ saved: true });
    }
    
    let unsubscribe = formStore.subscribe(state => {
      console.log('formStore changed', state);
    });
        

    “Dawei gives us the store behavior we want — without the noise.”
    — The Sparkstone Team

    View source