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

@oh-my-ghaad/react

v0.0.13

Published

React integration for Oh My GHAAD, providing a hook to easily use Git repositories as JSON databases in your React applications.

Readme

@oh-my-ghaad/react

React integration for Oh My GHAAD, providing a hook to easily use Git repositories as JSON databases in your React applications.

Overview

The React package provides a useGHaaD hook that integrates the core Engine with React's state management system, allowing you to:

  • Access the Engine instance in your React components
  • Subscribe to Engine updates
  • Track repository status changes

Installation

npm install @oh-my-ghaad/react @oh-my-ghaad/core
# or
yarn add @oh-my-ghaad/react @oh-my-ghaad/core
# or
pnpm add @oh-my-ghaad/react @oh-my-ghaad/core

Basic Usage

import { Engine } from '@oh-my-ghaad/core';
import { GithubAdapter } from '@oh-my-ghaad/adapter-github';
import { useGHaaD } from '@oh-my-ghaad/react';
import { useEffect, useState } from 'react';
import { z } from 'zod';

// Define your collection schema
const widgetSchema = z.object({
  id: z.string(),
  name: z.string(),
  type: z.enum(['gauge', 'chart', 'counter']),
  config: z.object({
    color: z.string(),
    size: z.enum(['small', 'medium', 'large']),
    enabled: z.boolean()
  })
});

// Create a collection
const widgetsCollection = {
  id: 'widgets',
  names: {
    singular: 'widget',
    plural: 'widgets',
    path: 'widgets'
  },
  validator: widgetSchema,
  idFunction: () => crypto.randomUUID()
};

// Create the engine instance
const engine = new Engine({
  adapters: [new GithubAdapter()],
  collections: [widgetsCollection],
  appConfig: {
    persisted: true
  }
});

// Use the hook in your component
function WidgetsList() {
  const { engine, repoStatus, lastUpdated } = useGHaaD(engine);
  const [widgets, setWidgets] = useState<z.infer<typeof widgetSchema>[]>([]);
  const [loading, setLoading] = useState(true);

  // Fetch widgets when the component mounts or when lastUpdated changes
  useEffect(() => {
    async function fetchWidgets() {
      try {
        setLoading(true);
        const items = await engine.fetchCollectionItems('widgets');
        setWidgets(items);
      } catch (error) {
        console.error('Failed to fetch widgets:', error);
      } finally {
        setLoading(false);
      }
    }

    fetchWidgets();
  }, [lastUpdated]); // Re-fetch when the engine updates

  if (loading) {
    return <div>Loading widgets...</div>;
  }

  return (
    <div>
      <div>Repository Status: {repoStatus}</div>
      {widgets.map(widget => (
        <div key={widget.id}>
          <h3>{widget.name}</h3>
          <p>Type: {widget.type}</p>
          <p>Size: {widget.config.size}</p>
          <button
            onClick={async () => {
              try {
                await engine.updateInCollection('widgets', widget.id, {
                  ...widget,
                  config: {
                    ...widget.config,
                    enabled: !widget.config.enabled
                  }
                });
              } catch (error) {
                console.error('Failed to update widget:', error);
              }
            }}
          >
            Toggle Enabled
          </button>
        </div>
      ))}
    </div>
  );
}

API Reference

useGHaaD Hook

function useGHaaD(
  engine: Engine,
  subscription?: Subscription
): {
  engine: Engine;
  repoStatus: RepoStatus;
  lastUpdated: number;
}

The hook returns:

  • engine: The Engine instance
  • repoStatus: Current status of the repository
  • lastUpdated: Timestamp of the last update

Related Packages

For more examples and detailed usage, see the main README and the demo app.