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

@cocrepo/store

v1.0.13

Published

Global state management library using MobX

Readme

@cocrepo/store

Global state management library using MobX for the Cocrepo monorepo.

Overview

@cocrepo/store provides centralized state management for authentication, navigation, routing, and application-wide state using MobX observables and reactions.

Features

  • 🔐 Authentication Store - User authentication state and token management
  • 🧭 Navigation Store - Route navigation and history management
  • 🍪 Cookie Store - Cookie-based state persistence
  • 💾 Storage Store - LocalStorage/SessionStorage abstraction
  • 🎯 Plate Store - Root store composition and initialization
  • 🚀 Token Store - JWT token lifecycle management

Installation

pnpm add @cocrepo/store

Usage

Basic Setup

import { PlateStore } from '@cocrepo/store';
import { observer } from 'mobx-react-lite';

// Create root store instance
const plateStore = new PlateStore();

// Use in React components
const MyComponent = observer(() => {
  const { authStore, navigation } = plateStore;

  return (
    <div>
      {authStore?.isLoggingOut ? 'Logging out...' : 'Active'}
    </div>
  );
});

Store Providers

import { AppProviders } from '@cocrepo/store';

function App() {
  return (
    <AppProviders>
      <YourApp />
    </AppProviders>
  );
}

Using Individual Stores

import { AuthStore, NavigationStore } from '@cocrepo/store';
import { observer } from 'mobx-react-lite';

const LoginPage = observer(() => {
  const handleLogin = async () => {
    // AuthStore handles authentication logic
  };

  return <button onClick={handleLogin}>Login</button>;
});

Store Architecture

PlateStore (Root)
├── AuthStore - Authentication & session management
├── NavigationStore - Route & navigation state
│   ├── NavigatorStore - Navigation actions
│   └── RouteStore - Route definitions
├── TokenStore - JWT token handling
├── CookieStore - Cookie operations
└── StorageStore - Persistent storage

API Reference

PlateStore

Root store that initializes and composes all child stores.

class PlateStore {
  name: string;
  navigation?: NavigationStore;
  tokenStore?: TokenStore;
  authStore?: AuthStore;
  cookieStore?: CookieStore;
}

AuthStore

Manages authentication state and HTTP interceptors.

class AuthStore {
  isLoggingOut: boolean;
  handleAuthError(error: unknown): void;
}

NavigationStore

Handles routing and navigation state.

class NavigationStore {
  routes: RouteStore[];
  currentRoute?: RouteDto;
  setCurrentRoute(route: RouteDto): void;
}

Testing

# Run tests
pnpm test

# Watch mode
pnpm test:watch

Dependencies

  • mobx - Reactive state management
  • mobx-react-lite - React bindings for MobX
  • @cocrepo/api - API client utilities
  • @cocrepo/toolkit - Shared utility functions

Best Practices

  1. Always use observer - Wrap components that consume store state with observer HOC
  2. Avoid direct mutations - Use MobX actions for state changes
  3. Initialize once - Create PlateStore instance at app root
  4. Use reactions wisely - Leverage MobX reactions for side effects

Migration from @cocrepo/frontend

If you're migrating from @cocrepo/frontend:

// Before
import { PlateStore, useAuth } from '@cocrepo/frontend';

// After
import { PlateStore, useAuth } from '@cocrepo/store';

License

ISC