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

@durion/react

v0.2.5

Published

Durion React hooks for workflow stream state + Gateway v0 token SSE

Readme

@durion/react

Universal React hooks for Durion workflows (Temporal + Gateway HTTP API).

Quick Start — useRunStream (recommended)

A single hook that merges SSE token streaming + polled stream-state. Pass a runId and get back real-time text, run status, and metadata.

import { useRunStream, useSendSignal } from '@durion/react';

function ChatResponse({ runId }: { runId: string }) {
  const { text, status, run, error } = useRunStream(runId, {
    baseURL: '',        // same-origin or your gateway URL
    accessToken: token, // optional
    pollIntervalMs: 1000,
    onToken: (delta) => console.log(delta),
  });

  const { send } = useSendSignal({ baseURL: '' });

  if (error) return <div>Error: {error.message}</div>;
  if (status === 'waiting_for_input') {
    return <button onClick={() => send(runId, { approved: true })}>Approve</button>;
  }

  return <div>{text}</div>;
}

What useRunStream does internally

  1. Opens EventSource to GET /v0/runs/:id/token-stream → accumulates text deltas
  2. Polls GET /v0/runs/:id/stream-state → provides run metadata (status, step count, messages)
  3. Falls back to polled partialReply if SSE misses early tokens

useSendSignal

Sends signals (e.g. HITL input) to a running workflow via POST /v0/runs/:id/signal.

const { send, isSending, error } = useSendSignal({ baseURL: '', accessToken });
await send(runId, { approved: true });
await send(runId, 'some text', 'custom:signal-name'); // custom signal name

Low-level hooks (escape hatches)

For non-gateway or custom paths:

| Concern | Hook | Notes | |---------|------|-------| | Token SSE | useWorkflowTokenStream | Requires getTokenStreamUrl(runId). Has subscribeThenStart for zero-drop. | | Polled UI state | useWorkflowStreamState | Requires custom queryFn. |


Gateway v0 helpers

URL builders and pre-wired wrappers for the standard Gateway API v0 paths (names omit “v0”; URLs still use /v0/...):

| Helper | Purpose | |--------|---------| | useGatewayTokenStream | SSE via GET /v0/runs/:id/token-stream | | useGatewayStreamState | Polls GET /v0/runs/:id/stream-state | | gatewayWorkflowsStartUrl | URL builder for POST /v0/workflows/start | | gatewaySignalUrl | URL builder for POST /v0/runs/:id/signal | | gatewayResultUrl | URL builder for GET /v0/runs/:id/result | | createGatewayStreamStateQueryFn | Factory for poll queryFn |

Note: These are now considered low-level. Prefer useRunStream for new code.


Run-scoped streaming

useRunStream takes a runId, optional baseURL, and optional gateway token — the same shape you’d use for any client that opens an SSE URL and polls run metadata against your HTTP API (e.g. Gateway API v0), not a vendor-hosted endpoint.


Peer dependency

  • react ^18 or ^19