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

@arc-dev/client-react

v0.1.1-alpha.12

Published

React hooks and components for the ARC Registry client

Readme

@arc-dev/client-react

Beautiful React hooks and components for the Arc Registry. Makes it incredibly easy to run Arcs with automatic input handling, state management, and clean component patterns.

Installation

npm install @arc-dev/client-react
# or
pnpm add @arc-dev/client-react
# or
yarn add @arc-dev/client-react

Quick Start

1. Wrap your app with ArcProvider

import { ArcProvider } from "@arc-dev/client-react";

function App() {
  return (
    <ArcProvider config={{ baseUrl: "https://arc-registry.example.com" }}>
      <YourApp />
    </ArcProvider>
  );
}

2. Use the useArc hook to run an Arc

import { useArc } from "@arc-dev/client-react";

function MyComponent() {
  const [state, { run, resume, reset }] = useArc("my-arc");

  const handleStart = () => {
    run({ initialValue: "Hello" });
  };

  const handleProvideInput = (input: string) => {
    resume(input);
  };

  // Arc completed successfully
  if (state.isCompleted) {
    return (
      <div>
        <h2>Result</h2>
        <pre>{JSON.stringify(state.finalState, null, 2)}</pre>
        <button onClick={reset}>Run Again</button>
      </div>
    );
  }

  // Arc is paused and waiting for input
  if (state.isPaused) {
    return (
      <div>
        <h2>Arc needs your input</h2>
        <p>Current state: {JSON.stringify(state.currentState)}</p>
        <InputForm onSubmit={handleProvideInput} />
      </div>
    );
  }

  // Arc is running
  if (state.isRunning) {
    return <Spinner text="Arc is running..." />;
  }

  // Error occurred
  if (state.error) {
    return (
      <div>
        <h2>Error</h2>
        <p>{state.error.message}</p>
        <button onClick={reset}>Try Again</button>
      </div>
    );
  }

  // Initial state - ready to start
  return <button onClick={handleStart}>Start Arc</button>;
}

API Reference

ArcProvider

Provider component that makes the Arc client available to all child components.

<ArcProvider
  config={{
    baseUrl: "https://arc-registry.example.com",
    apiKey: "your-api-key",
    timeout: 30000,
  }}
>
  <App />
</ArcProvider>

Props:

  • config?: ArcClientConfig - Configuration for the Arc client
  • client?: ArcClient - Optional pre-configured client instance

useArc(arcId, options)

Main hook for running an Arc with automatic state management and input handling.

Parameters:

  • arcId: string - The ID of the Arc to run
  • options?: UseArcOptions - Optional callbacks and configuration

Returns: [state, actions]

State:

{
  isRunning: boolean;
  isPaused: boolean;
  isCompleted: boolean;
  error: Error | null;
  sessionId: string | null;
  finalState: State | null;
  finalContext: Context | null;
  currentState: State | null;
  currentContext: Context | null;
  events: ArcEvent[];
}

Actions:

{
  run: (initialState?: Partial<State>) => Promise<void>;
  resume: (input: any) => Promise<void>;
  reset: () => void;
}

useArcList(autoLoad?)

Hook for listing available Arcs from the registry.

function ArcList() {
  const { arcs, isLoading, error, reload } = useArcList();

  if (isLoading) return <Spinner />;
  if (error) return <Error error={error} />;

  return (
    <div>
      <button onClick={reload}>Reload</button>
      <ul>
        {arcs.map((arc) => (
          <li key={arc.id}>
            <strong>{arc.id}</strong>: {arc.description}
          </li>
        ))}
      </ul>
    </div>
  );
}

Parameters:

  • autoLoad?: boolean - Whether to automatically load the list on mount (default: true)

Returns:

{
  arcs: ArcCapability[];
  isLoading: boolean;
  error: Error | null;
  reload: () => Promise<void>;
}

useArcClient()

Hook to access the Arc client directly from context.

function CustomComponent() {
  const client = useArcClient();

  const handleCustomOperation = async () => {
    const metadata = await client.metadata("my-arc");
    console.log("Models used:", metadata.models);
  };

  return <button onClick={handleCustomOperation}>Get Metadata</button>;
}

Advanced Usage

With Event Callbacks

function EventLogger() {
  const [state, { run }] = useArc("my-arc", {
    onEvent: (event) => {
      console.log("Event:", event.type, event);
    },
    onComplete: (finalState, finalContext) => {
      console.log("Completed with state:", finalState);
    },
    onPause: (sessionId, state, context) => {
      console.log("Paused at session:", sessionId);
    },
    onError: (error) => {
      console.error("Error:", error);
    },
  });

  return <button onClick={() => run()}>Run Arc</button>;
}

Multiple Input Handling

The hook automatically handles Arcs that pause multiple times for input:

function MultiStepForm() {
  const [state, { run, resume }] = useArc("multi-step-arc");
  const [userInput, setUserInput] = useState("");

  const handleSubmitInput = () => {
    resume(userInput);
    setUserInput("");
  };

  if (state.isPaused) {
    return (
      <div>
        <h2>
          Step {state.events.filter((e) => e.type === "node-paused").length}
        </h2>
        <input
          value={userInput}
          onChange={(e) => setUserInput(e.target.value)}
          placeholder="Enter your input"
        />
        <button onClick={handleSubmitInput}>Continue</button>
      </div>
    );
  }

  if (state.isCompleted) {
    return <div>All done! {JSON.stringify(state.finalState)}</div>;
  }

  return <button onClick={() => run()}>Start Multi-Step Arc</button>;
}

Streaming Output

function StreamingOutput() {
  const [output, setOutput] = useState("");

  const [state, { run }] = useArc("streaming-arc", {
    onEvent: (event) => {
      if (event.type === "node-output-delta") {
        setOutput((prev) => prev + (event.delta || event.chunk || ""));
      }
    },
  });

  return (
    <div>
      <button onClick={() => run()}>Start</button>
      <pre>{output}</pre>
    </div>
  );
}

TypeScript Support

The hook is fully typed with generics:

interface MyArcState {
  text: string;
  result?: string;
}

interface MyArcContext {
  model: string;
  tokens: number;
}

function TypedComponent() {
  const [state, { run }] = useArc<MyArcState, MyArcContext>("my-arc");

  useEffect(() => {
    if (state.finalState) {
      // TypeScript knows finalState has 'text' and 'result' properties
      console.log(state.finalState.result);
    }
  }, [state.finalState]);

  return <button onClick={() => run({ text: "Hello" })}>Run</button>;
}

Examples

See the examples directory for complete working examples including:

  • Basic Arc execution
  • Multi-step forms with input handling
  • Streaming output display
  • Error handling patterns
  • Event logging

License

Apache-2.0 - Copyright 2025 ARC PLATFORM LTD