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

react-state-custom

v1.0.33

Published

Turn any React hook into global state. No boilerplate, no complexity—just pure, performant state management.

Readme

React State Custom

The "It's Just a Hook" State Manager for React.

Turn any React hook into a global store. Zero boilerplate. Full type safety. Automatic lifecycle management.

Demo npm version License: MIT

npm install react-state-custom

🎮 Try the Live Demo →


⚡ The 30-Second Pitch

Stop writing reducers, actions, and manual providers. If you can write a React hook, you've already written your store.

// 1. Write a standard hook (your store logic)
const useCountState = ({ initial = 0 }) => {
  const [count, setCount] = useState(initial)
  const increment = () => setCount(c => c + 1)
  return { count, increment }
}

// 2. Create a store
export const { useStore } = createStore('counter', useCountState)

// 3. Setup (mount once at root) & Use anywhere
function App() {
  return (
    <>
      <AutoRootCtx /> {/* 👈 The magic that manages your stores */}
      <Counter />
    </>
  )
}

function Counter() {
  const { count, increment } = useStore({ initial: 10 })
  return <button onClick={increment}>{count}</button>
}

That's it. No Provider wrapping per store. No complex setup. Just hooks.


🚀 Why React State Custom?

Most state libraries force you to learn a new way to write logic (reducers, atoms, proxies). React State Custom lets you use the React skills you already have.

💎 Zero Boilerplate

Define state with useState, useEffect, useMemo. No new syntax to learn.

🎯 Selective Re-renders

Components only re-render when the specific data they use changes. Performance is built-in.

🔄 Automatic Lifecycle

Stores are created when needed and destroyed when unused. No more manual cleanup or memory leaks.

🛡️ TypeScript First

Full type inference out of the box. Your IDE knows exactly what's in your store.


🛠️ Quick Start

1. Define Your State

Write a hook that returns the data and actions you want to share.

// features/userState.ts
import { useState, useEffect } from 'react'

export const useUserState = ({ userId }: { userId: string }) => {
  const [user, setUser] = useState(null)
  
  useEffect(() => {
    fetchUser(userId).then(setUser)
  }, [userId])

  return { user, isLoading: !user }
}

2. Create the Store

Use createStore to generate a hook for your components.

import { createStore } from 'react-state-custom'
import { useUserState } from './features/userState'

export const { useStore: useUserStore } = createStore('user', useUserState)

3. Mount the Root (Once)

Add <AutoRootCtx /> to your app's root. This component manages all your stores automatically.

// App.tsx
import { AutoRootCtx } from 'react-state-custom'

export default function App() {
  return (
    <>
      <AutoRootCtx />
      <YourAppContent />
    </>
  )
}

🎭 Isolated State

Need to run multiple independent instances of your application or isolate features? Use StateScopeProvider.

import { AutoRootCtx, StateScopeProvider } from 'react-state-custom'

function App() {
  return (
    <>
      <AutoRootCtx /> {/* Global Scope */}
      <MainApp />

      <StateScopeProvider>
         {/* Isolated Scope - Stores here are independent of Global Scope */}
         <IsolatedFeature />
      </StateScopeProvider>
    </>
  )
}

Stores used inside StateScopeProvider will be completely isolated from the parent or global scope, even if they share the same store definition.


🆚 Comparison

| Feature | React State Custom | Redux | Context API | Zustand | |:---|:---:|:---:|:---:|:---:| | Paradigm | Just Hooks 🪝 | Actions/Reducers | Providers | Store Object | | Boilerplate | 🟢 None | 🔴 High | 🟡 Medium | 🟢 Low | | Auto Lifecycle | ✅ Yes | ❌ No | ❌ No | ❌ No | | Selective Renders | ✅ Automatic | ⚠️ Selectors | ❌ Manual | ✅ Selectors | | Learning Curve | 🟢 Low | 🔴 High | 🟡 Medium | 🟢 Low |


🧩 Advanced Features

🔌 Developer Tools

Inspect your state in real-time with the built-in DevTools.

import { DevToolContainer } from 'react-state-custom'
import 'react-state-custom/dist/react-state-custom.css'

<DevToolContainer />

🆔 Parameterized Stores

Create multiple independent instances of the same store by passing different parameters.

// Creates a unique store for each ID
const { count } = useStore({ id: 'counter-1' })
const { count } = useStore({ id: 'counter-2' })

⚡️ Derived State

Compose stores just like hooks.

const useCartTotal = () => {
  const { items } = useCartStore({})
  return items.reduce((total, item) => total + item.price, 0)
}

📦 Installation

npm install react-state-custom
# or
yarn add react-state-custom

📖 Documentation

📄 License

MIT © Vo Thanh Dat