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

@sewdn/workflow-react

v0.1.1

Published

React bindings of the workflow client: a provider, hooks for queries, commands and changes on Effect's reactivity atoms, the UI ports of an application, and the copy catalogs.

Readme

@sewdn/workflow-react

React bindings of the workflow client (@sewdn/workflow-client): a provider, hooks for the runtime's reads, its commands and its changes, the UI ports an application gives the workflow's screens, and the copy catalogs. Built on Effect's reactivity atoms (effect/reactivity) and their React binding @effect/atom-react, both 4.1.4.

Spike: Effect atoms or TanStack Query

Checked on 2026-11-16 against the registry and the installed sources.

  • What exists. [email protected] ships effect/reactivity: Atom, AtomRegistry, AsyncResult, Reactivity (invalidation by key), AtomRpc (atoms straight over an RPC group) and Hydration. The React binding is @effect/atom-react, released in lockstep with effect (versions 4.0.6 … 4.1.4, latest 4.1.4; peers effect ^4.1.4, react >=19 <20, scheduler >=0.25 <0.29). Its source is five small files: RegistryProvider, useAtomValue, useAtom, useAtomSet (with a promise mode), useAtomRefresh, useAtomMount, useAtomSuspense, useAtomSubscribe, hydration helpers. The older @effect-atom/atom-react (0.7.0) is for Effect 3 (effect ^3.22) and does not fit. TanStack Query: @tanstack/react-query 5.107.1.
  • Bundle size, minified with bun build --minify --target=browser, on top of what the page already loads for the client (effect's RPC client and server, ManagedRuntime, Stream, Schema, react-dom): atoms and their React binding add 35.3 kB (11.3 kB gzip); TanStack Query adds 43.9 kB (13.1 kB gzip). The atoms reuse the effect already on the page.
  • Suspense. Both have it: useAtomSuspense (suspends while Initial, optionally while refreshing; a failure is thrown to the error boundary) and useSuspenseQuery.
  • Invalidation after a command and on changes. Atoms: Reactivity invalidates by key, Atom.withReactivity refreshes an atom when its key is invalidated, and the subscription to changes is itself an atom (a Stream) that invalidates on every commit. TanStack: queryClient.invalidateQueries from a useEffect over the async iterable. Equal in power; the atoms keep the subscription and the invalidation in one Effect program.
  • Typed errors. Atoms keep the error type in AsyncResult<A, E> (here the client's WorkflowClientError, whose code narrows its params). TanStack Query types errors through a global Register declaration, one type for the whole application.
  • An application that already uses TanStack Query. It keeps its own QueryClient for its own data; the workflow's reads live in the provider's atom registry and refresh themselves on changes, so the application never invalidates them. One thing it must not expect: the workflow's reads are not in its query cache (no shared devtools, no queryClient.getQueryData on them). Where it needs a workflow read inside its own query, it calls the promise facade (createWorkflowClient) in its queryFn and invalidates on useChanges.
  • AtomRpc would put atoms directly on the RPC client, but its Service binds the protocol layer when the module is loaded; the provider takes a client at render time, so the atoms here are built per client over the facade.

Choice: Effect atoms (the brief's default). No blocker found: the binding exists for the pinned version, is the smaller of the two, and covers suspense, invalidation and typed errors.

The provider

import { createWorkflowClient } from "@sewdn/workflow-client";
import { WORKFLOW_COPY_EN, WorkflowProvider } from "@sewdn/workflow-react";

const client = createWorkflowClient({ ports, config }); // or a layer of the Effect client: client={layer}

<WorkflowProvider
  client={client}
  plugins={[]}
  copy={WORKFLOW_COPY_EN}
  actor={viewer}
  ui={{ links, people, timeZone }}
>
  <App />
</WorkflowProvider>;
  • client: the facade (the host keeps and disposes it) or a Layer<WorkflowRpcClient> over any transport (the provider makes a facade from it and disposes it shortly after unmounting).
  • plugins: the application's WorkflowPlugin[], the same list the runtime is given (layerPlugins). The provider installs their engine parts on the page (installPlugins) and gives their UI parts to the components below.
  • copy: WORKFLOW_COPY_EN, WORKFLOW_COPY_NL, or a WorkflowCopy of the application's own. The plugins' words join its catalog (withPluginCopy), so useCopy() words a plugin's refusal (plugin.refused) and a check's veto (command.vetoed) through the plugin's copy.
  • actor: who acts when a command call names no one.
  • ui: WorkflowUiPorts, each optional: links (stand-in: plain anchors), people (no stand-in: usePeople throws without it), documents (stand-in: none), timeZone (stand-in: the browser's), announce (stand-in: silent).

Each provider has its own atom registry and one subscription to the client's changes. Every commit (and the first Subscribed, which covers commits made before the subscription stood) invalidates the reactivity key workflow, and every read refreshes. Every command the provider gives invalidates it too when the call settles, success or failure, so the read after a command does not wait for its change. A broken subscription is made again after a second; a refused one (a server refuses changes to an external viewer) is not asked again: useLive() turns false and reads refresh after own commands, on refresh, when the window regains focus and when the display clock (ui.clock, useClock()) moves.

Hooks

| Hook | Gives | | ------------------------------------------------------------------------------- | ----------------------------------------------------- | | useWorld(options?), useSequence(options?), useRuns(query?, options?) | QueryState of the read | | useRun(runId, options?), useOverview(…), usePhases(…) | QueryState, data undefined for no such run | | useHistory(runId, options?), useTaskList(personId, options?) | QueryState of the lines / the person's work | | useWorkflowQuery(ref, params, { viewer?, enabled? }) | QueryState of an engine query, gated, as the viewer | | usePhaseTask, useStep, useStepOutlook, useFollowUps, useRunFollow | the run screens' engine queries, gated, as the viewer | | useAdHocTasks, useAdHocTask, useGroups, useDefinitions, useVersions | the same | | useReturnPreview(work), useRights(runId?) | a return's dry run; { can(capability), status } | | useAsk() | (ref, params) => Promise: one fresh answer, now | | useLive(), useClock() | whether changes streams; the display's clock | | useCommand(name) | { execute, pending, executed, failure, reset } | | usePluginCommand(plugin, name) | the same, typed by the plugin's command | | usePluginQuery(plugin, name, params, { viewer?, enabled? }) | QueryState of the plugin's query, as the viewer | | useChanges(listener?) | the last Change; the listener hears every one | | useCopy() | refusal, finding, failure, history, trigger | | usePlugins(), useActor() | the registered plugins, the provider's actor | | useLinks(), usePeople(), useDocuments(), useTimeZone(), useAnnounce() | the UI ports, or their stand-ins |

Plugins

WorkflowPlugin<R> = { id, engine, runtime?, ui? }: the engine part (@sewdn/workflow-engine), the runtime part (@sewdn/workflow-runtime, R the services its binding uses) and the UI part typed here, PluginUiPart: the editor's inspectors (inspectors.triggers, inspectors.taskKinds), a run screen's taskViews and the forms' controls, each keyed by the name of what it renders (the plugin's id is its own). A plugin package exports its parts as subpaths (./engine, ./runtime, ./react), so a server never loads the UI.

A field control gets FieldControlProps: the field's pointer in the form's values (nested fields included, e.g. /visits/1/site), the form's element id for it, label, description, required, value, onChange, schema, enabled and errors. FieldControlFrame of @sewdn/workflow-forms draws the form's frame around it (label, description, draft, revision, read-only text, the errors at the pointer): <FieldControlFrame {...props} readOnlyText={…}>{(a11y) => <input {...a11y} />}</FieldControlFrame>.

WorkflowPluginsProvider (rendered by WorkflowProvider, usable alone where there is no client yet) installs the engine parts and gives the list to usePlugins(), useTriggerInspector(ref), useTaskKindInspector(ref), useTaskView(ref) and pluginControls(plugins), all by reference (<plugin>.<name>). Keep the list's identity stable: a new list installs again.

QueryState<A> is { status: "loading" | "success" | "failure", data, failure, refreshing, refresh }; after a failure data keeps the last answer. useCommand(name).execute(input, call?) never rejects: it resolves with { ok: true, executed } or { ok: false, failure }, where failure is the client's WorkflowClientError (failure.kind === "refused" and failure.code narrow failure.params). call may give actor, commandId (default: a fresh one per call; give the same id again to retry a call whose outcome is unknown), correlationId and causationId.

Plugin data

A plugin's commands and queries are typed by its definition, the same object given to plugins and to the runtime:

const schedule = usePluginCommand(docketPlugin, "schedule");
const outcome = await schedule.execute({ meetingId, runId }); // { ok: true, executed } with executed.value.entryId
const meetings = usePluginQuery(docketPlugin, "meetings", { seriesId }); // QueryState of the query's result
  • usePluginCommand(plugin, name) behaves as useCommand: execute(input, call?) never rejects, the actor defaults to the provider's, the command id to a fresh one. The input is checked by the command's schema before it is sent (client.invalid-request); a plugin's refusal is plugin.refused { command, ref, params }.
  • usePluginQuery(plugin, name, params, options?) asks the query as options.viewer, by default the provider's actor, so a runtime with a gate table (queryGates) answers what that person may see, and a query the gate closes fails with query.not-found. Params made in render are compared by their JSON. Every commit refreshes it, as every read.
  • The engine's own hooks (useWorld, useRuns, …) read the host-trusted typed reads, which no gate filters: a screen shown to external people reads through useWorkflowQuery or plugin queries, never through them.
  • useWorkflowQuery(ref, params, options?) asks an engine query (workflow.runs, workflow.phases, workflow.commits, … ENGINE_QUERY_PARAMS) through the facade's gated query, as options.viewer (by default the provider's actor). Its params are typed by EngineQueryParams<R> and its data by EngineQueryResult<R> of the runtime; a run that does not exist, or a query the gate closes, fails with query.not-found.
  • useDraft(versionId, options?) and useDraftHistory(versionId, { after?, limit? }, options?) read a draft through workflow.draft and workflow.draft-history as the viewer: the version with the viewer's own undo and redo tops (data.undo.edit is what useCommand("undoEdit") names), and the history oldest first, kept after the publish, which useCopy().draftLine(line, nameOf?) puts in words. A viewer without the workflow.author right gets query.not-found. Every commit refreshes both, so another author's edit arrives as a new revision and line.
  • Every read hook takes enabled (default true). enabled: false holds the read back: it is loading, sends no request and is not refreshed by commits until it is enabled (a read that waits for a persona or a choice).

Failures and read states

failureFacts(failure) gives { code, field?, params } (the input field a refusal names). readState(query) gives "loading", "not-found" (query.not-found: what does not exist, or what a gate keeps from the viewer), "error" (any other failure with nothing to show) or undefined (data to show). useCopy().failure(failure) words any failure.

Links

useLinks() returns every member of WorkflowLinks: the application's, else a stock one over hash addresses (stockHref: #/runs/<id>, #/tasks/ad-hoc/<id>, #/records/<plugin>/<type>/<id>, …) and page loads. Only Link is required; a stock EntityLink or useOpenEntity uses the application's href when it gives one.

Testing

@sewdn/workflow-react/testing (tests and stories only): TestWorkflowProvider { genesis?, seed?, actor?, plugins?, copy?, people?, ui?, config?, intercept?, onReady? } mounts a WorkflowProvider over a fresh runtime on the memory adapter (the plugins' runtime parts are not bound). intercept holds a query loading or fails it (queries, by reference), fails a command without sending it (commands, by name), or holds or refuses changes. Port fakes: testPeople(persons), recordingLinks() (what was opened and navigated to), testClock(start).

Scripts

bun run typecheck
bun run test     # vitest run (jsdom, React Testing Library)
bun run build    # tsc -p tsconfig.build.json