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

controllex

v0.0.2-alpha

Published

A simple, predictable state management library for JavaScript applications

Downloads

201

Readme



Why ControlleX?

ControlleX is a framework-agnostic state management library designed for developers who want:

  • Simplicity — Get started in minutes, not hours
  • 🎯 Predictability — Explicit state changes, easy debugging
  • 📦 Zero dependencies — Just pure JavaScript
  • 🔌 Framework adapters — React support built-in, Vue/Angular coming soon
  • 💾 Persistence — Built-in localStorage plugin

Unlike complex solutions like Redux, ControlleX requires no boilerplate, no action constants, and no middleware setup.


Installation

npm install controllex

Quick Start

Level 1: Ultra Simple (For Beginners)

import { createStore } from 'controllex';

// Create a store with initial state
const store = createStore({
  initialState: {
    count: 0,
    user: null
  }
});

// Read state
console.log(store.getState().count); // 0

// Update state
store.setState({ count: 1 });

// Update with current state
store.setState(state => ({ count: state.count + 1 }));

// Subscribe to changes
const unsubscribe = store.subscribe(() => {
  console.log('State changed:', store.getState());
});

// Stop listening
unsubscribe();

With React

import { createStore } from 'controllex';
import { useStore } from 'controllex/react';

// Create your store
const counterStore = createStore({
  initialState: { count: 0 }
});

// Use in components
function Counter() {
  const count = useStore(counterStore, state => state.count);
  
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => counterStore.setState(s => ({ count: s.count + 1 }))}>
        Increment
      </button>
    </div>
  );
}

Level 2: Advanced Usage (For Larger Apps)

Using Slices

Organize your state into logical slices:

import { createSlice, createStore } from 'controllex';

// Define a counter slice
const counterSlice = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: {
    increment: (state) => ({ ...state, value: state.value + 1 }),
    decrement: (state) => ({ ...state, value: state.value - 1 }),
    incrementBy: (state, amount: number) => ({ 
      ...state, 
      value: state.value + amount 
    }),
  }
});

// Create store with the slice's initial state
const store = createStore({
  initialState: counterSlice.getInitialState()
});

// Use auto-generated actions
const action = counterSlice.actions.increment();
const newState = counterSlice.reducer(store.getState(), action);
store.setState(newState);

Persistence

Keep your state across page reloads:

import { createStore } from 'controllex';
import { persist } from 'controllex/plugins';

const store = createStore({
  initialState: { 
    theme: 'dark',
    user: null,
    temporaryData: []
  }
});

// Persist only specific keys
const persistedStore = persist(store, {
  key: 'my-app-state',
  whitelist: ['theme', 'user'], // Don't persist temporaryData
});

Documentation

Full documentation is available in the /docs/en folder:

📖 Documentação em Português


Examples

Todo App

import { createStore } from 'controllex';

interface Todo {
  id: number;
  text: string;
  completed: boolean;
}

const todoStore = createStore({
  initialState: {
    todos: [] as Todo[],
    filter: 'all' as 'all' | 'active' | 'completed'
  }
});

// Add todo
const addTodo = (text: string) => {
  todoStore.setState(state => ({
    todos: [...state.todos, { id: Date.now(), text, completed: false }]
  }));
};

// Toggle todo
const toggleTodo = (id: number) => {
  todoStore.setState(state => ({
    todos: state.todos.map(todo =>
      todo.id === id ? { ...todo, completed: !todo.completed } : todo
    )
  }));
};

// Remove todo
const removeTodo = (id: number) => {
  todoStore.setState(state => ({
    todos: state.todos.filter(todo => todo.id !== id)
  }));
};

React Todo Component

import { useStore } from 'controllex/react';

function TodoList() {
  const todos = useStore(todoStore, state => state.todos);
  
  return (
    <ul>
      {todos.map(todo => (
        <li key={todo.id}>
          <input
            type="checkbox"
            checked={todo.completed}
            onChange={() => toggleTodo(todo.id)}
          />
          <span style={{ textDecoration: todo.completed ? 'line-through' : 'none' }}>
            {todo.text}
          </span>
          <button onClick={() => removeTodo(todo.id)}>Delete</button>
        </li>
      ))}
    </ul>
  );
}

API Reference

See API_CONTRACT.md for the complete API reference.

Core

| Function | Description | |----------|-------------| | createStore(config) | Creates a new state store | | createSlice(config) | Creates a slice with auto-generated actions |

Store Methods

| Method | Description | |--------|-------------| | store.getState() | Returns current state | | store.setState(partial \| updater) | Updates state | | store.subscribe(listener) | Subscribes to changes |

React Hooks

| Hook | Description | |------|-------------| | useStore(store, selector?) | Subscribe to store with optional selector | | createStoreHook(store) | Create a typed hook for a store | | useStoreDispatch(store) | Get the setState function |

Plugins

| Function | Description | |----------|-------------| | persist(store, config) | Add persistence to a store | | clearPersistedState(key) | Clear persisted state |


Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.


License

MIT © Plinio Mabesi