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

@runtypelabs/react-flow

v0.1.7

Published

React Flow adapter for building visual flow editors with Runtype

Readme

@runtypelabs/react-flow

A React Flow adapter for building visual flow editors with Runtype. This package provides pre-built node components and hooks for creating, editing, and saving flows using the Runtype API.

Official React Flow adapter published on npm

Running the Example

From the monorepo root, run:

pnpm dev:react-flow-example

This will build the package and start the example app at http://localhost:3100

Installation

pnpm add @runtypelabs/react-flow @xyflow/react

Quick Start

import { RuntypeFlowEditor } from '@runtypelabs/react-flow'
import { createClient } from '@runtypelabs/sdk'
import '@xyflow/react/dist/style.css'

const client = createClient({
  apiKey: 'your-api-key',
})

function MyFlowEditor() {
  return (
    <div style={{ width: '100%', height: '600px' }}>
      <RuntypeFlowEditor
        client={client}
        flowId="optional-flow-id"
        onSave={(flow) => console.log('Saved:', flow)}
      />
    </div>
  )
}

Features

  • Pre-built Node Components: Ready-to-use nodes for prompt, fetch URL, code, conditional, and send email steps
  • API Integration: Seamlessly load, save, and create flows using @runtypelabs/sdk
  • Validation: Built-in validation for all step types
  • Auto-layout: Automatic node positioning
  • Fully Typed: Complete TypeScript support

Supported Step Types

| Step Type | Node Component | Description | | ---------------- | --------------- | --------------------------------------- | | prompt | PromptNode | AI text generation with model selection | | fetch-url | FetchUrlNode | HTTP requests to fetch data | | transform-data | CodeNode | JavaScript code execution | | conditional | ConditionalNode | Branch execution based on conditions | | send-email | SendEmailNode | Send emails |

Components

RuntypeFlowEditor

The main editor component that wraps React Flow with Runtype integration.

<RuntypeFlowEditor
  client={runtypeClient}
  flowId="optional-existing-flow-id"
  initialName="My Flow"
  initialDescription="A description"
  initialSteps={[]}
  onSave={(flow) => {...}}
  onChange={(nodes, edges) => {...}}
  onStepSelect={(step) => {...}}
  showToolbar={true}
  readOnly={false}
  className="my-editor"
/>

Props:

| Prop | Type | Description | | -------------------- | ------------------------ | ------------------------------------------------ | | client | RuntypeClient | Required. Runtype API client instance | | flowId | string | ID of an existing flow to load | | initialName | string | Initial flow name for new flows | | initialDescription | string | Initial flow description | | initialSteps | FlowStep[] | Initial steps to populate | | onSave | (flow) => void | Callback when flow is saved | | onChange | (nodes, edges) => void | Callback when flow changes | | onStepSelect | (step) => void | Callback when a step is selected | | showToolbar | boolean | Whether to show the toolbar (default: true) | | readOnly | boolean | Whether the editor is read-only (default: false) | | className | string | Custom class name for the container |

Hooks

useRuntypeFlow

Manages flow state and API operations.

import { useRuntypeFlow } from '@runtypelabs/react-flow'

function MyCustomEditor() {
  const {
    nodes,
    edges,
    onNodesChange,
    onEdgesChange,
    onConnect,
    flowName,
    setFlowName,
    loadFlow,
    saveFlow,
    createFlow,
    addStep,
    deleteStep,
    updateStep,
    isLoading,
    isSaving,
    error,
    hasUnsavedChanges,
  } = useRuntypeFlow({
    client,
    flowId: 'optional-flow-id',
  })

  // Use with ReactFlow
  return (
    <ReactFlow
      nodes={nodes}
      edges={edges}
      onNodesChange={onNodesChange}
      onEdgesChange={onEdgesChange}
      onConnect={onConnect}
    />
  )
}

useFlowValidation

Validates flow steps and returns errors/warnings.

import { useFlowValidation } from '@runtypelabs/react-flow'

function ValidationStatus({ nodes }) {
  const { result, getStepErrors, getStepWarnings } = useFlowValidation({ nodes })

  return (
    <div>
      <p>Valid: {result.isValid ? 'Yes' : 'No'}</p>
      <p>Errors: {result.errors.length}</p>
      <p>Warnings: {result.warnings.length}</p>
    </div>
  )
}

Utilities

Adapter Functions

Convert between Runtype flow steps and React Flow nodes:

import {
  flowStepsToNodes,
  nodesToFlowSteps,
  createEdgesFromNodes,
  createDefaultStep,
} from '@runtypelabs/react-flow'

// Convert Runtype steps to React Flow nodes
const nodes = flowStepsToNodes(steps, {
  onChange: (stepId, updates) => {...},
  onDelete: (stepId) => {...},
})

// Convert back to Runtype steps
const steps = nodesToFlowSteps(nodes)

// Create edges between nodes
const edges = createEdgesFromNodes(nodes)

// Create a new default step
const newStep = createDefaultStep('prompt', 0)

Layout Functions

Auto-layout nodes for better visualization:

import { autoLayout, centerNodes, snapToGrid } from '@runtypelabs/react-flow'

// Auto-layout nodes based on edges
const layoutedNodes = autoLayout(nodes, edges, {
  direction: 'vertical',
  startPosition: { x: 400, y: 50 },
})

// Center nodes in viewport
const centeredNodes = centerNodes(nodes, viewportWidth, viewportHeight)

// Snap nodes to grid
const snappedNodes = snapToGrid(nodes, 20)

Custom Node Components

You can use individual node components directly:

import {
  PromptNode,
  FetchUrlNode,
  CodeNode,
  ConditionalNode,
  SendEmailNode,
  BaseNode,
} from '@runtypelabs/react-flow'

// Register with ReactFlow
const nodeTypes = {
  prompt: PromptNode,
  'fetch-url': FetchUrlNode,
  'transform-data': CodeNode,
  conditional: ConditionalNode,
  'send-email': SendEmailNode,
}

<ReactFlow nodeTypes={nodeTypes} ... />

TypeScript

Full TypeScript support with exported types:

import type {
  FlowStep,
  RuntypeNode,
  RuntypeEdge,
  RuntypeNodeData,
  PromptStepConfig,
  FetchUrlStepConfig,
  TransformDataStepConfig,
  ConditionalStepConfig,
  SendEmailStepConfig,
  FlowValidationResult,
  ValidationError,
  ValidationWarning,
  SavedFlow,
} from '@runtypelabs/react-flow'

Development Notes

TypeScript

This package exports TypeScript types directly from source files to ensure compatibility across different React versions. TypeScript users will get full type inference automatically.

Peer Dependencies

This package requires the following peer dependencies:

  • react ^18.0.0
  • react-dom ^18.0.0
  • @xyflow/react ^12.0.0

Styling

Import React Flow's styles in your application:

import '@xyflow/react/dist/style.css'

License

MIT