FormFlow Component

The base component for building custom forms. Handles submission, validation, loading states, and success/error handling.

Import

import { FormFlow } from '@formflow.sh/react';

Basic Usage

import { FormFlow, Input, Textarea, SubmitButton } from '@formflow.sh/react';

function CustomForm() {
  return (
    <FormFlow
      apiKey="ff_live_xxx"
      onSuccess={(data) => console.log('Submitted:', data)}
    >
      <Input name="email" type="email" label="Email" required />
      <Textarea name="message" label="Message" />
      <SubmitButton>Send</SubmitButton>
    </FormFlow>
  );
}

Props

PropTypeRequiredDescription
apiKeystringNo*Your FormFlow API key. Optional in development.
formIdstringNoCustom form identifier for analytics
onSuccess(data) => voidNoCalled after successful submission
onError(error) => voidNoCalled on submission error
successMessagestringNoCustom success message
redirectUrlstringNoURL to redirect after success
theme"minimal" | "modern" | "brutalist" | "glass"NoVisual theme (default: minimal)
classNamestringNoAdditional CSS classes
childrenReactNodeYesForm fields (Input, Select, etc.)

With All Options

<FormFlow
  apiKey="ff_live_xxx"
  formId="custom-contact"
  theme="modern"
  successMessage="Thanks for reaching out!"
  onSuccess={(data) => {
    console.log('Submission ID:', data.submissionId);
    analytics.track('form_submitted', { formId: 'custom-contact' });
  }}
  onError={(error) => {
    console.error('Submission failed:', error);
    toast.error('Something went wrong. Please try again.');
  }}
  className="max-w-md mx-auto"
>
  <Input name="name" label="Name" required />
  <Input name="email" type="email" label="Email" required />
  <SubmitButton>Send Message</SubmitButton>
</FormFlow>

Development Mode

When no API key is provided, FormFlow runs in development mode:

  • Submissions are logged to the browser console
  • No data is sent to the server
  • Success callbacks still fire
  • Perfect for testing and prototyping

Context API

FormFlow provides a context that child components can access:

import { useFormFlow } from '@formflow.sh/react';

function CustomField() {
  const { isSubmitting, theme, formData } = useFormFlow();

  return (
    <div className={isSubmitting ? 'opacity-50' : ''}>
      {/* Custom field implementation */}
    </div>
  );
}

Available Child Components

FormFlow Component - Build Custom React Forms | FormFlow