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

react-form-atlas

v1.3.1

Published

React hooks and components for React Form Atlas

Readme

react-form-atlas

npm version License: MIT

Official React Hooks for React Form Atlas. Build complex branching forms with simple hooks.

📦 Installation

npm i react-form-atlas

⚡ Quick Start

Try on StackBlitz

import { useReactForm } from 'react-form-atlas';

// Define your map
const schema = {
  initial: 'welcome',
  states: {
    welcome: { on: { NEXT: 'details' } },
    details: { on: { SUBMIT: 'success' } },
    success: { type: 'final' }
  }
};

export default function MyForm() {
  const { 
    currentStep, // Current node ID (e.g., 'welcome')
    transition,  // Function to move to next node
    back,        // Function to go back
    progress,    // 0-100%
    isReady      // true when engine is initialized
  } = useReactForm({
    schema,
    autoSave: true
  });

  if (!isReady) return <p>Loading...</p>;

  return (
    <div className="p-4">
      {/* Progress Bar */}
      <div className="h-2 bg-gray-200 rounded">
        <div 
          className="h-full bg-blue-500 transition-all duration-300" 
          style={{ width: `${progress}%` }} 
        />
      </div>

      {/* Render Steps */}
      {currentStep === 'welcome' && (
        <StepOne onNext={() => transition('NEXT')} />
      )}
      
      {currentStep === 'details' && (
        <StepTwo onSubmit={() => transition('SUBMIT')} />
      )}

      {currentStep === 'success' && <h1>🎉 Done!</h1>}

      {/* Back Button */}
      <button onClick={back} disabled={progress === 0}>
        Back
      </button>
    </div>
  );
}

📚 API Reference

useReactForm(options)

Options

| Option | Type | Description | | :--- | :--- | :--- | | schema | object | Required. The graph definition. | | autoSave | boolean | Enable IndexedDB persistence (Default: false). | | storageKey | string | Unique key for storage (Default: 'React Form Atlas'). | | onComplete | func | Callback when a final state is reached. |

Returns

| Value | Type | Description | | :--- | :--- | :--- | | currentStep | string | ID of the current active node. | | transition | func | (event: string, payload?: any) => void | | back | func | Go to the previous step. | | progress | number | Calculated completion (0-100). | | context | object | The collected form data so far. | | updateContext | func | Manually update form data. |

📄 License

MIT © Mehul Birare

import { useReactForm } from 'react-form-atlas';
import type { FormSchema } from 'react-form-atlas-engine';

const schema: FormSchema = {
  id: 'onboarding',
  initial: 'welcome',
  states: {
    welcome: { id: 'welcome', on: { NEXT: 'userType' } },
    userType: {
      id: 'userType',
      on: {
        SELECT_BUSINESS: 'businessDetails',
        SELECT_INDIVIDUAL: 'personalDetails'
      }
    },
    businessDetails: { id: 'businessDetails', on: { NEXT: 'complete' } },
    personalDetails: { id: 'personalDetails', on: { NEXT: 'complete' } },
    complete: { id: 'complete' }
  }
};

function MyForm() {
  const {
    currentState,
    context,
    progress,
    canGoBack,
    transition,
    back,
    updateContext,
    isReady
  } = useReactForm({
    schema,
    autoSave: true,
    onComplete: (data) => {
      console.log('Form completed!', data);
    }
  });

  if (!isReady) return <div>Loading...</div>;

  return (
    <div>
      {/* Progress Bar */}
      <div className="progress-bar">
        <div style={{ width: `${progress}%` }} />
      </div>

      {/* Step Content */}
      {currentState === 'welcome' && (
        <div>
          <h1>Welcome!</h1>
          <button onClick={() => transition('NEXT')}>
            Get Started
          </button>
        </div>
      )}

      {currentState === 'userType' && (
        <div>
          <h2>Select Account Type</h2>
          <button onClick={() => transition('SELECT_BUSINESS')}>
            Business
          </button>
          <button onClick={() => transition('SELECT_INDIVIDUAL')}>
            Individual
          </button>
        </div>
      )}

      {/* Navigation */}
      {canGoBack && (
        <button onClick={back}>Back</button>
      )}
    </div>
  );
}

Features

  • ⚛️ React Hooks: Clean, idiomatic React API
  • 🔄 Auto-Updates: Component re-renders on state changes
  • 💾 Auto-Save: Built-in state persistence
  • 📊 Progress Tracking: Real-time progress updates
  • 🎯 TypeScript: Full type safety

API

useReactForm(options)

Options:

  • schema: FormSchema - Form schema (required)
  • autoSave?: boolean - Enable auto-save
  • storageKey?: string - Custom storage key
  • onStepChange?: (event) => void - Step change callback
  • onComplete?: (context) => void - Completion callback
  • onError?: (error) => void - Error callback

Returns:

  • currentState: string - Current state ID
  • context: FormContext - Current form data
  • progress: number - Progress percentage (0-100)
  • canGoBack: boolean - Whether back navigation is available
  • possibleNextStates: string[] - Possible next states
  • transition: (event, data?) => Promise<void> - Transition function
  • back: () => Promise<void> - Go back function
  • updateContext: (data) => Promise<void> - Update context
  • reset: () => Promise<void> - Reset form
  • engine: FormEngine - Access to engine instance
  • isReady: boolean - Whether engine is initialized

Examples

See the examples directory for complete implementations.

License

MIT