Docs
v1.3.14
GitHubSite
Getting started / Introduction

Introduction

FieldCraft is a schema-driven form engine for React. Define a form once in JSON — sections, fields, conditions, validation, scoring — and the renderer builds it.

What FieldCraft does

You write a JSON schema that describes a form — its fields, sections, validation rules, conditional logic, and submission behaviour. FieldCraft reads that schema and renders a fully functional form with zero imperative code.

import { FormRenderer } from '@squaredr/fieldcraft-react'
import schema from './patient-intake.json'

export default function IntakePage() {
  return (
    <FormRenderer
      schema={schema}
      theme="clinical"
      onSubmit={async (response) => {
        await fetch('/api/intake', {
          method: 'POST',
          body: JSON.stringify(response),
        })
      }}
    />
  )
}

The schema drives everything: which fields appear, when they appear, how they validate, what happens when the user submits. You never write onChange handlers, manage form state, or wire up validation manually.

Architecture

Two packages, each depending only on the one beneath it. Take the layer you need and nothing more.

LayerPackageWhat it does
Core@squaredr/fieldcraft-coreSchema parsing, state management, condition evaluation, validation, expression engine, navigation. No UI, no React.
React@squaredr/fieldcraft-react<FormRenderer />, 44 field components, 4 hooks, theming system with 6 presets, draft persistence, step navigation.

Core is framework-agnostic. You could build a Vue or Svelte renderer on top of it — the engine API is the same. React is the official renderer that ships with the project.

What the engine handles

ConcernHow it works
Conditional visibilityAny field or section can declare showIf — a condition expression evaluated against current form values. Hidden fields are excluded from validation and submission.
Validation12 built-in rule types (required, min/max, minLength/maxLength, pattern, email, phone, URL, date, file size, file type) plus custom sync and async validators. Validation runs on blur, on section change, and on submit.
Multi-step navigationSections become steps. The engine tracks which sections are visible, which have been visited, and whether the current section is valid before allowing forward navigation.
Computed fieldsExpressions like {price} * {quantity} are parsed and evaluated safely — no eval(). Dependencies are tracked so computed fields update when their inputs change.
Draft persistenceAnswers survive a page refresh with zero configuration. Drafts are keyed by schema ID + session token, stored in localStorage by default, or sent to a server via a draft adapter.
Schema validation at bootA malformed schema throws FormEngineSchemaError at engine creation time — not on the user's first keystroke. Duplicate field IDs, invalid conditions, and missing required properties are caught before rendering.
ScoringFields can carry numeric scores. The engine aggregates them and maps totals to named ranges (e.g., "Low risk", "Medium risk", "High risk").
Submission pipelineResponses go through adapters — HTTP, Supabase, Postgres, webhooks — with retry logic, HMAC signing, and field-level encryption.

Packages at a glance

PackagenpmLicence
@squaredr/fieldcraft-corev1.3.14MIT
@squaredr/fieldcraft-reactv1.2.12MIT
@squaredr/fieldcraft-adaptersv1.0.1MIT
@squaredr/fieldcraft-templates-freev1.1.1MIT

Next steps

If you want to start building immediately, go to Installation.

If you want to understand the schema format first, start with Schema anatomy.

If you already have FieldCraft installed and want a guided walkthrough, try Your first form.

On this page