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

redux-neat

v1.2.0

Published

An opinionated and simple way to use Redux

Readme

redux-neat

An opinionated and simple way to use Redux.

Bundle size Tests Status Version MIT

Contents

Features

  • Zero boilerplate - Single create() function to set up your entire Redux store.
  • Full TypeScript support - Actions and selectors are fully typed with inference.
  • Mutable syntax - Write handlers that mutate state directly (powered by Immer).
  • Nested organization - Group related handlers and getters in nested objects.
  • React integration - Selectors are React hooks that subscribe to state changes.
  • Redux DevTools - Automatic integration with Redux DevTools browser extension.

Installation

npm i redux-neat
# or
yarn add redux-neat
# or
pnpm add redux-neat

Note: This library requires react and react-dom as peer dependencies.

Quick Start

import {create} from 'redux-neat'

// 1. Create store with handlers and getters
const {store, actions, selectors, getters} = create(
  {count: 0}, // initial state
  {
    handlers: {
      increment: (state) => {
        state.count++
      },
      add: (state, n: number) => {
        state.count += n
      },
    },
    getters: {
      count: (state) => state.count,
    },
  }
)

// 2. Use actions to update state
actions.increment()
actions.add(5)

// 3. Use selectors in React components (they are hooks!)
function Counter() {
  const count = selectors.count()
  return <div>{count}</div>
}

// 4. Use getters outside of React
const currentCount = getters.count()

That's it! No action types, no action creators, no reducers. Just handlers and getters.

Exploring the API

The library exports a single function create and some TypeScript types:

import {create} from 'redux-neat'
import type {StoreConfig, Handlers, Getters} from 'redux-neat'

Defining handlers

Handlers are functions that update the state. They receive the current state as the first argument and can receive additional arguments:

const {actions} = create<State>(initialState, {
  handlers: {
    // Handler with no extra arguments
    reset: (state) => {
      state.count = 0
    },
    // Handler with one argument
    add: (state, n: number) => {
      state.count += n
    },
    // Handler with multiple arguments
    addMultiple: (state, a: number, b: number) => {
      state.count += a + b
    },
  },
  getters: {},
})

// Call actions (state argument is not passed, it's handled internally)
actions.reset()
actions.add(5)
actions.addMultiple(2, 3)

Handlers can mutate the state directly.

Defining getters

Getters are functions that derive data from the state. They are returned as React hooks (selectors) to use inside components, and as regular functions (getters) to use outside of React:

const {selectors, getters} = create<State>(initialState, {
  handlers: {},
  getters: {
    // Simple getter
    count: (state) => state.count,
    // Getter with arguments
    countPlusN: (state, n: number) => state.count + n,
    // Computed values
    isPositive: (state) => state.count > 0,
  },
})

// In a React component
function MyComponent() {
  const count = selectors.count()
  const countPlus10 = selectors.countPlusN(10)
  const isPositive = selectors.isPositive()
  // ...
}

// Outside of React
const currentCount = getters.count()
const currentCountPlus10 = getters.countPlusN(10)
const currentlyPositive = getters.isPositive()

Using nested handlers and getters

You can organize handlers and getters in nested objects for better code organization:

type State = {
  user: {name: string; age: number}
  settings: {theme: 'light' | 'dark'}
}

const {actions, selectors, getters} = create<State>(initialState, {
  handlers: {
    user: {
      setName: (state, name: string) => {
        state.user.name = name
      },
      birthday: (state) => {
        state.user.age++
      },
    },
    settings: {
      toggleTheme: (state) => {
        state.settings.theme = state.settings.theme === 'light' ? 'dark' : 'light'
      },
    },
  },
  getters: {
    user: {
      name: (state) => state.user.name,
      age: (state) => state.user.age,
    },
    settings: {
      theme: (state) => state.settings.theme,
    },
  },
})

// Actions mirror the nested structure
actions.user.setName('Alice')
actions.user.birthday()
actions.settings.toggleTheme()

// Selectors mirror the nested structure (in React components)
const name = selectors.user.name()
const theme = selectors.settings.theme()

// Getters mirror the nested structure (outside of React)
const currentName = getters.user.name()
const currentTheme = getters.settings.theme()

In Redux DevTools, nested actions appear with dot notation: user.setName, user.birthday, settings.toggleTheme.

Using selectors in React components

Selectors are React hooks that use useSelector from react-redux under the hood. Your app needs to be wrapped with Provider:

import {Provider} from 'react-redux'
import {create} from 'redux-neat'

const {store, actions, selectors} = create<State>(initialState, config)

// Wrap your app with Provider
function App() {
  return (
    <Provider store={store}>
      <Counter />
    </Provider>
  )
}

// Use selectors in components
function Counter() {
  const count = selectors.count()
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => actions.increment()}>+</button>
      <button onClick={() => actions.decrement()}>-</button>
    </div>
  )
}

Disabling Redux DevTools

By default, redux-neat connects to Redux DevTools if available. You can disable this:

const {store, actions, selectors} = create<State>(initialState, {
  handlers,
  getters,
  withDevTools: false,
})

Changelog

See CHANGELOG.md for release history.