Skip to content
TheChatArchiveThe Chat Archive
Amazon Novaamazon-nova-experimental-chat-05-14· AmazonHugging Face LMArena Human Preference 140K

i need something like zustand for vanillajs or any other js based lib that does not…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514-thinking-32k’s answer.
  1. User

    i need something like zustand for vanillajs or any other js based lib that does not involve building step.

  2. Amazon Nova Assistant

    Certainly! If you're looking for a state management library similar to Zustand but for vanilla JavaScript (or any JavaScript-based library) that doesn't require a build step, here are a few options you can consider:

    1. Simple State Manager (SSM)

    Simple State Manager (SSM) is a tiny, zero-dependency state management library for vanilla JavaScript.

    Features:

    • Lightweight: ~300B min+gzip.
    • Simple API: Easy to learn and use.
    • No Build Step: Can be used directly in the browser with a script tag.

    Usage:

    <script src="https://unpkg.com/ssm@1.0.0/dist/ssm.min.js"></script>
    <script>
      const state = SSM({
        count: 0
      });
    
      state.subscribe((state) => {
        console.log(state.count); // Logs state changes
      });
    
      state.update((state) => {
        state.count++;
      });
    </script>
    

    2. Nanostores

    Nanostores is another lightweight state management library that works with vanilla JavaScript. It’s designed to be framework-agnostic and can be used without a build step

    Features:

    • Tiny: The core library is less than 1KB gzipped.
    • Framework-agnostic: Works with any JavaScript framework or plain JavaScript.
    • No Build Step: Can be included via a script tag.

    Usage

    <script src="https://unpkg.com/nanostores@0.5.12/dist/nanostores.iife.js"></script>
    <script>
      const { store } = Nanostores;
    
      const countStore = store(0);
    
      countStore.listen((value) => {
        console.log(value); // Logs state changes
      });
    
      countStore.set(countStore.get() + 1); // Increment count
    </script>
    

    3. Tinybase

    Tinybase is a lightweight, in-memory database and state management library. It is less than 5KB gzipped and has no dependencies.

    Features:

    • Lightweight: ~4.5KB min+gzip.
    • In-Memory Database: Can be used for more complex state management.
    • No Build Step: Can be included via a script tag
    • Reactive: Supports subscriptions to state changes.

    Usage:

    <script src="https://unpkg.com/tinybase@3.1.0/dist/tinybase.iife.js"></script>
    <script>
      const {Store} = tinybase;
    
      const store = new Store();
      store.setTable("main", {count: 0});
    
      store.subscribe((update) => {
        if (update.tableId === "main" && update.rowId === "count") {
          console.log(store.getCell("main", "count")); // Logs state changes
        }
      });
    
      store.setCell("main", "count", store.getCell("main", "count") + 1); // Increment count
    </script>
    

    4. Valtio

    Valtio is a lightweight, proxy-based state management library inspired by Zustand. It can be used in vanilla JavaScript and doesn't require a build step when using the UMD build.

    Features:

    • Proxy-based: Uses JavaScript Proxies for reactive state.
    • Lightweight: ~1.5KB min+gzip.
    • No Build Step: UMD build available for direct script inclusion.
    • Simple API: Similar to Zustand, making it easy to transition.

    Usage:

    <script src="https://unpkg.com/valtio@1.10.3/dist/valtio.iife.js"></script>
    <script>
      const { proxy, subscribe } = valtio;
    
      const state = proxy({ count: 0 });
    
      subscribe(state, () => {
        console.log(state.count); // Logs state changes
      });
    
      state.count++; // Increment count
    </script>
    

    5. Signals

    Signals is a reactive state management library that works with vanilla JavaScript. It is extremely lightweight and can be used without a build step.

    Features

    • Reactive: Automatically tracks and updates dependencies.
    • Lightweight: Core library is less than 1KB gzipped
    • No Build Step: Can be included via a script tag.
    • Simple API: Easy to use and understand.

    Usage:

    <script src="https://unpkg.com/@preact/signals@1.1.3/dist/iife/signals.js"></script>
    <script>
      const { signal, effect } = Signals;
    
      const count = signal(0);
    
      effect(() => {
        console.log(count.value); // Logs state changes
      });
    
      count.value++; // Increment count
    </script>
    

    Any of these libraries can serve as a lightweight, no-build-step alternative to Zustand for your vanilla JavaScript projects. Choose the one that best fits your project's needs and your personal preference for API design.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.