onFormComplete()

This event handler runs when a user completes the entire form.

Overview

onFormComplete is a <Feathery.Form> prop and callback function to access and modify form state when a user completes the form. It is called a single time per form flow and runs after any other lifecycle events like submission or load. This function can be asynchronous.

The form completion event is defined as when the user completes the form in the same session or returns to a completed form that has edits disabled.

Detect Form Completion in Mobile Embed

iOS Webkit

When the form is completed, Feathery will send the message Form completed through a WebKit message handler named feathery, if it exists.

Android WebView

Define an Android Javascript Interface and add it to the WebView where the Feathery form is loaded. Make sure to name your interface FeatheryInterface when adding it, and define an onComplete() method on the class. Feathery will call your onComplete() method when the form is completed.

React Native WebView

When the form is completed, Feathery will send the message Form completed through the React Native WebView message handler.

Usage

You can use onFormComplete to redirect the user, show a completion message, and more. The function takes a single Context object that provides form-related state and handlers.

import { init, Form } from '@feathery/react';

function App() {
  // Initialize Feathery
  init('SDKKey', 'bob@feathery.io');

  // Show the `aBcDeF` Feathery form
  return <Form
    formId='aBcDeF'
    // Route to a new webpage
    onFormComplete={(context) => {
      location.href = 'https://google.com';
    }}
  />
}

Context API

Return value

A promise can be optionally returned from this function if it's asynchronous and you want execution to await.

Last updated