# onFormComplete()

### Overview

`onFormComplete` is a [\<Feathery.Form>](/develop/react/api-guide/form.md) 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&#x20;

#### iOS Webkit

When the form is completed, Feathery will send the message `Form completed` through a [WebKit message handler](https://developer.apple.com/documentation/webkit/wkscriptmessagehandler) named `feathery`, if it exists.

#### Android WebView

Define an Android Javascript Interface and [add it to the WebView](https://developer.android.com/reference/android/webkit/WebView#addJavascriptInterface\(java.lang.Object,%20java.lang.String\)) 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](https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#postmessagestr).

### Usage <a href="#usage" id="usage"></a>

You can use `onFormComplete` to redirect the user, show a completion message, and more. The function takes a single [Context](#context-api) 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) => {
      context.openUrl("https://google.com")
    }}
  />
}
```

### Context API

|                   Key                   | Type | Description                                     |
| :-------------------------------------: | :--: | ----------------------------------------------- |
| [Form Context](/develop/context-api.md) |      | Consistently available form state and functions |

### Return value

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.feathery.io/develop/react/api-guide/form/event-handlers/onformcomplete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
