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

@alphea/react

v0.1.5

Published

React hooks and Provider bindings for ALPHEA browser app runtimes

Readme

@alphea/react

React hooks and Provider bindings for ALPHEA browser app runtimes.

npm install @alphea/react react react-dom
npm install -D @types/react @types/react-dom
import {
  alpheaError,
  createAlpheaAppGatewayResolver,
  createAlpheaReactHooks,
  getAlpheaBrowserClient,
  isAlpheaErrorCode,
} from "@alphea/react";
import type { AlpheaFns } from "./alphea-fns.generated";

const alphea = createAlpheaReactHooks<AlpheaFns>();

export function NewNote() {
  const createNote = alphea.useFn("createNote");

  return (
    <button
      disabled={createNote.loading}
      onClick={() => void createNote.call({ title: "Hello" })}
    >
      Save
    </button>
  );
}

The hooks resolve the served runtime's ambient window.alphea binding by default. Use AlpheaProvider only when you want to inject an explicit client, for example in tests or a custom bootstrap.

@alphea/react is the normal browser-safe dependency for React UI apps. In addition to the hooks, it re-exports the browser Client Framework factories, ambient client helpers, shared JSON/error/function/worker types, and ALPN app resolver helpers so React app code does not need a direct @alphea/framework or @alphea/client dependency for those browser-safe surfaces.

Keep credential-bearing Foundation RPC clients, bearer/session transports, and auth login helpers in trusted tooling or server code that depends on @alphea/foundation; they are not exported by @alphea/react.

Connect hooks: @alphea/react/connect

The Connect bindings live behind a separate import, and that separation is the point rather than packaging trivia.

The root entry above is the browser-capability surface: an ambient session the served ALPHEA runtime holds on the app's behalf. @alphea/react/connect is the end-user Connect surface: a credential that belongs to a person who signed in. An ambient browser-capability session neither is, nor can create, a Connect session — so reaching the second is an explicit import, not something an app inherits from the first.

import {
  createAlpheaConnectAuthClient,
  createAlpheaConnectDataClient,
  createAlpheaConnectFetchTransport,
  createAlpheaConnectMemorySessionStore,
  createAlpheaConnectAccessTokenProvider,
} from "@alphea/connect";
import {
  AlpheaConnectProvider,
  useConnectPointBalance,
  useConnectSession,
} from "@alphea/react/connect";

const sessionStore = createAlpheaConnectMemorySessionStore();
const transport = createAlpheaConnectFetchTransport({
  baseUrl: import.meta.env.VITE_CONNECT_BASE_URL,
  getAccessToken: createAlpheaConnectAccessTokenProvider(sessionStore),
});

<AlpheaConnectProvider
  auth={createAlpheaConnectAuthClient({ transport, sessionStore })}
  data={createAlpheaConnectDataClient({ transport })}
>
  <App />
</AlpheaConnectProvider>;

You construct the clients and pass them in. There is no ambient fallback, because there is nothing ambient to find.

Hook state

Every hook reports one of idle, loading, success, error, unauthorized, or unavailable. The last two are separate from error because an app does something different for each:

const balance = useConnectPointBalance();

if (balance.unauthorized) return <SignInPrompt />;   // no valid session
if (balance.unavailable) return null;                // not served here
if (balance.error) return <Retry onRetry={balance.reload} />;

unavailable means the operation was not attempted: either it is not live in the pinned Connect contract, or the app listed it in unavailableOperations on the provider. A hook never reports an unavailable operation as a successful call.

Available hooks:

  • Session and sign-inuseConnectSession, useConnectSessionSnapshot, useConnectGoogleLogin, useConnectEmailLogin, useConnectLogout
  • PointsuseConnectPointBalance, useConnectPointSummary, useConnectPointHistory
  • Referral readsuseConnectReferralCode, useConnectFriends, useConnectReferralRewards, useConnectInviterBonus
  • Referral actionsuseConnectReferralActions, giving claimInviterBonus, claimReward, claimCompletionBonus, and redeemInvitation
  • Rounds and redeemuseConnectRoundStatus, useConnectRedeemStatus
  • WalletuseConnectWallets, useConnectWalletBinding

Each referral action takes a client-minted idempotency key, so a retried tap cannot double-award:

const referral = useConnectReferralActions();
await referral.claimReward.run({ level: 3, idempotencyKey });

Despite the shared word, these are not the reward-claim surface: they are point-ledger mutations the server settles, with nothing signed and no chain involved.

Reward-claim hooks are not in this release. They wait for a dedicated claim surface and its own contract review. Nothing in this entry reads a claim proof, builds calldata, or sends a transaction.