CLI

Overview

The formr-cli is a development tool for managing forms locally, validating schemas, and syncing with the API. It helps you work with forms in your development workflow.

Installation

Use via npx (no installation required):

npx formr-cli <command>

Or install globally:

npm install -g formr-cli

Authentication

Login

Authenticate with the Formr API:

npx formr-cli login

This will prompt for your API key and save it to ~/.formr/config.json.

Commands

init

Initialize Formr in your project.

Creates a .formr directory with configuration files.

What it does:

  • Creates .formr directory

  • Sets up configuration files

  • Prepares project for form development


infer

Infer form contract from HTML file or URL.

This analyzes an HTML form and generates a Formr schema automatically.

Use cases:

  • Migrate existing HTML forms

  • Convert forms from other systems

  • Quick form schema generation


validate

Validate form contract.

Validates form schemas for errors and issues before pushing to the API.

Checks:

  • Schema structure

  • Field definitions

  • Validation rules

  • Required fields


push

Push form contract to API.

Uploads local form schemas to the API. Use --apply to update existing forms.

Behavior:

  • Creates new forms if they don't exist

  • Shows warning if form exists (use --apply to update)

  • Updates existing forms when --apply is used


diff

Show diff between local and remote form.

Compares local form schema with the version on the API to see what has changed.

Use cases:

  • Review changes before pushing

  • See what's different between local and remote

  • Verify updates


pull

Pull form contract from API.

Downloads form schemas from the API. Supports multiple formats:

  • JSON (default)

  • YAML

  • TypeScript

Use cases:

  • Sync remote forms to local

  • Export forms for version control

  • Generate TypeScript types


types

Generate TypeScript types from forms.

Generates TypeScript type definitions for your forms based on their schemas.

Output:

  • Type definitions for form fields

  • Answer types

  • Form schema types


dev

Start dev server with mock submit and preview.

Starts a local development server for testing forms without submitting to the API.

Features:

  • Preview forms locally

  • Mock form submissions

  • Hot reload

  • Development-friendly workflow


Configuration

Store API credentials in ~/.formr/config.json or use environment variables:

  • FORMR_API_KEY - API key

  • FORMR_API_URL - API URL (default: https://api.formr.dev)

Config File Location

Environment Variables

Workflow Examples

Complete Development Workflow

Updating Existing Forms

Local Development

File Structure

After running init, your project will have:

Next Steps

  • Development Tools - Other development tools

  • SDK Guide - JavaScript/TypeScript SDK

  • React Components - React components

  • API Reference - Complete API documentation

Last updated