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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@godgpt/react

v0.1.1

Published

React bindings for GodGPT SDK with hooks and provider

Readme

@godgpt/react

React bindings for the GodGPT SDK with hooks and provider.

Installation

npm install @godgpt/core @godgpt/react
# or
pnpm add @godgpt/core @godgpt/react
# or
yarn add @godgpt/core @godgpt/react

Usage

Setup Provider

import { createSDK } from "@godgpt/core";
import { AuthModule } from "@godgpt/auth";
import { I18nModule } from "@godgpt/i18n";
import { SDKProvider } from "@godgpt/react";

// Create and configure SDK
const sdk = createSDK();
sdk.use(new AuthModule());
sdk.use(new I18nModule({ /* config */ }));

function App() {
  return (
    <SDKProvider
      sdk={sdk}
      onReady={() => console.log("SDK ready!")}
      onError={(error) => console.error(error)}
    >
      <MyApp />
    </SDKProvider>
  );
}

useSDK Hook

import { useSDK, useSDKReady } from "@godgpt/react";

function MyComponent() {
  const sdk = useSDK();
  const isReady = useSDKReady();

  if (!isReady) {
    return <div>Loading...</div>;
  }

  return <div>SDK is ready!</div>;
}

useAuth Hook

import { useAuth } from "@godgpt/react";

function AuthStatus() {
  const {
    isAuthenticated,
    isLoading,
    user,
    signIn,
    signOut,
  } = useAuth();

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

  if (isAuthenticated) {
    return (
      <div>
        <p>Welcome, {user?.name}!</p>
        <button onClick={() => signOut()}>Sign Out</button>
      </div>
    );
  }

  return (
    <button onClick={() => signIn("google")}>
      Sign In with Google
    </button>
  );
}

useTranslation Hook

import { useTranslation } from "@godgpt/react";

function MyComponent() {
  const { t, locale, setLocale, supportedLocales } = useTranslation();

  return (
    <div>
      <h1>{t("welcome")}</h1>
      <p>{t("greeting", { name: "World" })}</p>

      <select value={locale} onChange={(e) => setLocale(e.target.value)}>
        {supportedLocales.map((loc) => (
          <option key={loc} value={loc}>{loc}</option>
        ))}
      </select>
    </div>
  );
}

useEvent Hook

import { useEvent, useEmit } from "@godgpt/react";

function EventComponent() {
  const emit = useEmit();

  // Subscribe to events
  useEvent("custom:event", (data) => {
    console.log("Event received:", data);
  });

  // Emit events
  const handleClick = () => {
    emit("custom:event", { message: "Hello!" });
  };

  return <button onClick={handleClick}>Emit Event</button>;
}

useApi Hook

import { useApi } from "@godgpt/react";

function DataComponent() {
  const api = useApi();
  const [users, setUsers] = useState([]);

  useEffect(() => {
    api.get("/users").then(setUsers);
  }, [api]);

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

API Reference

Components

<SDKProvider>

Props:

  • sdk (SDK): The SDK instance
  • onReady (function): Called when SDK is initialized
  • onError (function): Called on initialization error

Hooks

useSDK()

Returns the SDK instance. Throws if used outside SDKProvider.

useSDKReady()

Returns true when SDK is initialized.

useAuth()

Returns auth state and methods:

  • isAuthenticated: boolean
  • isLoading: boolean
  • user: User object or null
  • signIn(provider, options?): Sign in function
  • signOut(): Sign out function

useTranslation()

Returns i18n state and methods:

  • t(key, options?): Translation function
  • locale: Current locale
  • setLocale(locale): Change locale
  • supportedLocales: Array of supported locales

useEvent(event, callback)

Subscribe to SDK events. Automatically unsubscribes on unmount.

useEmit()

Returns a function to emit SDK events.

useApi()

Returns the API module instance.

License

MIT