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

@stadojs/core

v1.0.0

Published

A lightweight, framework-agnostic state manager for JavaScript and TypeScript.

Readme

🧠 @stadojs/core

@stadojs/core es una librería minimalista, agnóstica a frameworks, para manejar estado global en aplicaciones modernas. Soporta sincronización entre pestañas (BroadcastChannel), persistencia (localStorage o sessionStorage), eventos locales (CustomEvent), y ahora también interceptores (middlewares) para monitorear cambios de estado.


🚀 Instalación

npm install @stadojs/core

🧰 API

defineGlobalStore<T>(name, initialState, options?): Store<T>

Crea un store global reactivo y configurable.

  • name: string – Nombre único del store.
  • initialState: T – Estado inicial.
  • options: StoreOptions – Opciones de configuración.
interface StoreOptions {
  broadcast?: BroadcastStrategy;
  persist?: boolean;
  storageType?: StorageType;
}

useGlobalStore<T>(name: string): Store<T>

Obtiene una instancia del store registrado por nombre.


emitGlobalStoreEvent<T>(name, data, target?): void

Emite un evento manual de estado a otras pestañas o la pestaña actual.


useStoreMiddleware<T>(middleware: (payload: { name: string, state: T }) => void): void

Registra una función global que se ejecutará cada vez que el estado de cualquier store cambie.


📦 Enumeraciones

BroadcastStrategy

  • None: No emite eventos.
  • Local: Usa CustomEvent para listeners en la pestaña actual.
  • CrossTab: Usa BroadcastChannel para comunicación entre pestañas.
  • All: Ambos métodos.

StorageType

  • Local: Almacena en localStorage.
  • Session: Almacena en sessionStorage.

🧪 Ejemplos de uso

1. Crear un store global con persistencia y comunicación entre pestañas

defineGlobalStore('auth', { token: '', user: null }, {
  broadcast: BroadcastStrategy.CrossTab,
  persist: true,
  storageType: StorageType.Local,
});

2. Usar un store en un microfrontend

const authStore = useGlobalStore<{ token: string; user: any }>('auth');

authStore.on((state) => {
  console.log('Auth actualizado:', state);
});

authStore.set({ token: 'abc123' });

3. Escuchar eventos manuales (otra pestaña)

window.addEventListener('store:auth', (e) => {
  console.log('Evento local recibido:', e.detail);
});

4. Emitir eventos entre pestañas manualmente

emitGlobalStoreEvent('auth', { token: 'externo', user: null }, BroadcastStrategy.All);

5. Registrar un middleware global para auditar todos los stores

useStoreMiddleware(({ name, state }) => {
  console.log(`[AUDIT] Store "${name}" cambió a:`, state);
});

Esto es ideal para:

  • Herramientas de monitoreo.
  • Logs de auditoría.
  • Debug en tiempo real.
  • Consolas de administración.

🗃️ Persistencia

  • Si persist está activado, el estado se guarda automáticamente en el tipo de almacenamiento elegido (localStorage o sessionStorage).
  • Se restaura automáticamente al volver a cargar la página.

🧩 Ideal para...

  • Microfrontends
  • Aplicaciones que abren múltiples pestañas
  • Sincronización de sesión
  • Aplicaciones offline
  • Herramientas administrativas

📜 Licencia

MIT