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

state-analyzer

v0.6.2

Published

Analyze Frontend state management patterns

Readme

State Analyzer

npm version license node version

Homepage · npm · 한국어


State Analyzer statically analyzes your Frontend codebase to detect state management patterns, measure complexity, and catch anti-patterns. It supports 11 state libraries, Next.js server/client detection, and custom plugin patterns.

Quick Start

# Install
npm install -g state-analyzer
# or: yarn global add state-analyzer / pnpm add -g state-analyzer / bun add -g state-analyzer

# Generate config
state-analyzer init

# Analyze
state-analyzer analyze ./src

Features

  • 11 Library Support — React hooks, Redux, Zustand, Jotai, MobX, Recoil, Valtio, TanStack Query, SWR
  • Next.js Support — Server/client component detection, route file classification, hook misuse warnings
  • Custom Hook Analysis — Detects custom hook definitions and traces internal state usage
  • Complexity Scoring — A~F grade per component and project-wide, --threshold for CI gate
  • Anti-pattern Detection — Unused state, excessive hooks (6+), library mixing (3+), useContext overuse
  • Multiple Outputs — Terminal, Markdown (--format md), Mermaid diagram (--mermaid), JSON
  • Diff Mode — Compare two analysis snapshots to track state changes over time
  • Watch Mode — Live re-analysis on file changes
  • Plugin System — Register custom state patterns via .stateanalyzerrc.json

Supported Libraries

| Library | Hooks Detected | |---------|---------------| | React | useState, useContext, useReducer | | Redux | useSelector, useDispatch, useStore | | Zustand | use*Store() patterns | | Jotai | useAtom, useAtomValue, useSetAtom | | MobX | observer, useLocalObservable | | Recoil | useRecoilState, useRecoilValue, useSetRecoilState | | Valtio | useSnapshot | | TanStack Query | useQuery, useMutation, useInfiniteQuery, useSuspenseQuery | | SWR | useSWR, useSWRMutation |

Usage

state-analyzer analyze ./src                # Basic analysis
state-analyzer analyze ./src --verbose      # Detailed output
state-analyzer analyze ./src --format md    # Markdown report
state-analyzer analyze ./src --mermaid      # Mermaid diagram
state-analyzer analyze ./src --output a.json # JSON export
state-analyzer analyze ./src --threshold C  # CI gate
state-analyzer diff before.json after.json  # Compare snapshots
state-analyzer watch ./src                  # Live watch

Options

| Option | Alias | Description | |--------|-------|-------------| | --output <file> | -o | Save results as JSON | | --verbose | -v | Show detailed component information | | --threshold <grade> | -t | Fail if complexity exceeds grade (A/B/C/D/F) | | --format <type> | -f | Output format: default, md | | --mermaid | - | Output Mermaid dependency diagram |

Example Output

=== Analysis Summary ===

Total components: 68
Components with state: 12 (17.6%)
Total state usage: 20
Average: 1.7 states/component
Custom hooks: 30
Environment: 8 client / 4 server

Usage by type:
  useState: 16
  Zustand: 4

=== Complexity ===

Project grade: A (score: 1.1)

Component grades:
  A ████████████████████ (64)
  B ██ (2)
  C ██ (2)

=== Suggestions ===

  ! ToastProvider (src/contexts/ToastContext.tsx)
    4 state hooks detected — consider extracting to a custom hook

Configuration

Create .stateanalyzerrc.json via state-analyzer init, or manually:

{
  "exclude": ["legacy/", "generated/"],
  "threshold": "C",
  "plugins": [
    {
      "name": "legend-state",
      "patterns": [{ "regex": "useObservable\\s*\\(", "type": "legend-state" }],
      "label": "Legend State"
    }
  ]
}

For full documentation, visit the Homepage.

Requirements

  • Node.js >= 16.0.0

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT