v1.3.0 — Now Available

React
Form
Atlas

Graph-based form engine that eliminates "condition hell" in complex multi-step workflows. Stop writing nested if-else. Start building state machines.

npm install react-form-atlas
View on GitHub Quick Start
0kb
Zero dependencies
0%
TypeScript native
Possible form paths
State Machine Forms
Dynamic Path Navigation
Auto Draft-Lock
Predictive Validation
Weighted Progress
Zero Dependencies
TypeScript Native
React 18 Ready
State Machine Forms
Dynamic Path Navigation
Auto Draft-Lock
Predictive Validation
Weighted Progress
Zero Dependencies
TypeScript Native
React 18 Ready

Core Features

Built for
Complexity.

Every form library handles the simple case. React Form Atlas handles the impossible one.

01 / 04

Dynamic Pathing

Navigation that adapts. Define your form as a finite state machine — not a series of nested if-else statements. The engine calculates valid transitions at runtime based on current context.

State Machine
02 / 04
🔒

Draft-Lock

Built-in persistence. Automatically saves form state to IndexedDB or LocalStorage so users never lose their progress — even on page refresh.

Auto-Persist
03 / 04
🎯

Predictive Validation

Prevent impossible states. The engine checks the entire future graph to ensure current data doesn't block completion before the user even gets there.

Future-Aware
04 / 04
⚖️

Weighted Progress

Real percentages — not fake ones. Calculate progress based on the actual complexity of the specific path the user is currently traversing. No more "99% done" that takes 10 minutes.

Path-Aware Progress

Architecture

The Mental Model.
Graph vs Linear.

React Form Atlas is a graph-based form engine that treats your form as a Directed Acyclic Graph (DAG) instead of a linear array of steps. This fundamental shift eliminates "condition hell" and makes complex branching logic declarative and maintainable.

Traditional Approach

Linear arrays ([Step1, Step2, Step3]) require complex imperative logic to handle branching. Resulting in brittle if/else soup.

React Form Atlas

Declarative graph schemas define nodes and edges. The engine handles navigation, history, and progress calculation automatically.

"Eliminate 'Condition Hell' — Build forms that scale from 5 to 500 steps without breaking a sweat."

Key Differentiators

States

Each step in your form is a state. States contain transitions, metadata (weight, validation), and custom properties like ARIA labels.

Transitions

Edges between states. They define the "map" of your form. Can be simple strings or complex conditional objects that evaluate context.

Context

The global state store. Accumulates data as users progress, shared across all form steps.

Draft-Lock

Automatic persistence via IndexedDB so users can resume exactly where they left off.

Path weights

Numerical weights assigned to states to make progress bar calculation accurate for every path.

Predictive Validation

Instead of validating only the current step, React Form Atlas validates the entire future path. If a user enters data that makes a future required step impossible to complete (e.g., age restriction), they are alerted immediately—preventing wasted time on intermediate steps.

Up in
Three Steps.

Step 01

Install the package

One command and you're set. The engine and bridge are separate so you can use the core headlessly.

Step 02

Define your schema

Describe states, transitions, and conditions as a plain JavaScript object — no DSL, no magic.

Step 03

Hook into your component

Use the hook anywhere in your tree. The engine manages transitions and context for you.
terminal

                            
                        

In-Depth Tutorial

Let's build a complete onboarding flow with conditional branching using the React bridge.

Step 1: Your Schema Map

Create a schema.ts file to define your form's topology. Notice the weight field—this is used for accurate progress calculation.

schema.ts
export const onboardingSchema = {
  id: 'onboarding',
  initial: 'welcome',
  states: {
    welcome: { on: { NEXT: 'userType' } },
    userType: {
      on: {
        BUSINESS: 'bizDetails',
        INDIVIDUAL: 'personalDetails'
      }
    },
    bizDetails: { on: { NEXT: 'complete' }, meta: { weight: 3 } },
    personalDetails: { on: { NEXT: 'complete' }, meta: { weight: 1 } },
    complete: { type: 'final' }
  }
};

Step 2: The React Component

Apply the useReactForm hook. It returns a stable object containing the current state and transition functions.

Form.tsx
import { useReactForm } from 'react-form-atlas';

function MyForm() {
  const { currentState, transition, progress, isReady } = 
    useReactForm({ 
      schema: onboardingSchema, 
      autoSave: true 
    });

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

  return (
    <div>
      <ProgressBar width={progress} />
      {currentState === 'welcome' && (
        <button onClick={() => transition('NEXT')}>Join</button>
      )}
    </div>
  );
}

Final Step: Add Visualization

Complex schemas can be hard to track. Use the visualizer CLI to generate an interactive map of your form.

npx react-form-atlas-visualizer schema.json -o map.html

API Reference

Every Method.
No Surprises.

The useReactForm hook returns a stable object — all methods are memoized.

Method / Property Params Description Returns
transition() event: string
data?: object
Move to the next state based on the schema graph. Fires guards and updates context atomically. Promise<void>
back() Navigate to the previous state in the history stack. Respects no-back flags per state. Promise<void>
updateContext() data: Partial<T> Deep-merge new data into the global form context without triggering a transition. void
progress Weighted completion percentage (0–100) of the current user-specific path. number
currentState The string key of the currently active schema state. string
context Live reference to the accumulated form context object. T
reset() Clear all context and history, returning to the initial state. Also purges any draft-lock storage. void

Detailed Reference

Every function in the engine is built for reliability. All state changes are atomic and irreversible (unless you move back).

transition(event: string, data?: object)
Returns: Promise<void> • Async: Yes

Evaluates guards for the given event, merges data into the global context, and updates the state. If no valid transition is found, it throws a TransitionError.

back()
Returns: Promise<void> • History-aware: Yes

Navigates to the previous state in the history stack. Respects the allowBack flag in your schema. Automatically syncs with storage.

updateContext(data: Partial<T>)
Returns: void • Performance: Targeted Update

Deep-merges new data into the form context without triggering state transitions. Useful for per-field validation or temporary UI state.

reset()
Returns: void • Destructive: Yes

Wipes all context, history, and storage snapshots. Returns the engine to its initial state—clean slate.

TypeScript Interfaces

React Form Atlas is built with 100% type safety. All schemas and hooks are strictly typed for a superior developer experience.

types.ts
interface FormSchema {
  id: string;
  initial: string;
  states: Record<string, FormState>;
}

interface FormState {
  id: string;
  on?: Record<string, string | ConditionalTransition>;
  meta?: {
    weight?: number;
    validation?: ValidationRule[];
  };
}

The Visualizer CLI

Generate documentation automatically from your code. Use the CLI tool to generate Mermaid diagrams or interactive HTML reports.

cli usage
react-form-atlas-visualizer <schema.json> --output report.html