Formclick

Ionic contact form

Use Ionic's form components and send each submission to Formclick with fetch. The same code runs in the browser and inside your Capacitor app.

Get your free access key Jump to the code

Set it up in 3 steps

  1. 1

    Get your access key

    Create a free Formclick account and copy the access key for your form from the dashboard. Submissions sent with that key are delivered to your inbox.

  2. 2

    Add the component

    Copy ContactForm into your Ionic React project, replace YOUR_ACCESS_KEY_HERE and render it inside an IonContent.

  3. 3

    Test on web and device

    Submit from ionic serve first, then from a device build. Both send to the same endpoint.

The code

Replace YOUR_ACCESS_KEY_HERE with the key from your dashboard. Before you start: An Ionic React project with @ionic/react installed..

ContactForm.tsx
import { useState } from 'react';
import {
  IonButton, IonInput, IonItem,
  IonLabel, IonTextarea, IonText,
} from '@ionic/react';

export default function ContactForm() {
  const [name, setName] = useState('');
  const [email, setEmail] = useState('');
  const [message, setMessage] = useState('');
  const [result, setResult] = useState('');

  async function handleSubmit() {
    setResult('Sending...');
    const res = await fetch(
      'https://api.formclick.io/submit',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          Accept: 'application/json',
        },
        body: JSON.stringify({
          access_key: 'YOUR_ACCESS_KEY_HERE',
          name, email, message,
        }),
      }
    );
    const data = await res.json();
    setResult(data.message);
  }

  return (
    <div>
      <IonItem>
        <IonLabel position="floating">Name</IonLabel>
        <IonInput
          onIonChange={e => setName(e.detail.value!)} />
      </IonItem>
      <IonItem>
        <IonLabel position="floating">Email</IonLabel>
        <IonInput type="email"
          onIonChange={e => setEmail(e.detail.value!)} />
      </IonItem>
      <IonItem>
        <IonLabel position="floating">Message</IonLabel>
        <IonTextarea
          onIonChange={e => setMessage(e.detail.value!)} />
      </IonItem>
      <IonButton expand="block" onClick={handleSubmit}>
        Submit
      </IonButton>
      {result && <IonText>{result}</IonText>}
    </div>
  );
}

Tips

  • On Ionic 7 and later, onIonInput fires on every keystroke and is usually the better choice than onIonChange.
  • Show the result in an IonToast for a native-feeling confirmation.
  • Using Angular or Vue? Make the same POST from your component. The request body is identical.

Ionic contact form FAQ

Does this work with Ionic Angular or Ionic Vue?

Yes. The example uses React, but Formclick only needs a POST request, so make the same call with HttpClient or fetch in Angular or Vue.

Is it safe to ship my access key in client code?

Yes. The access key only allows submissions to be sent to your account. It cannot read your data, open your dashboard or change your settings, and you can restrict it to specific domains.

Do I need my own server or backend?

No. Formclick receives the submission, filters spam, stores it in your dashboard and emails it to you. Your app only makes one POST request.

How much does it cost?

Core features are free forever. Paid plans add higher submission limits and extras like file uploads. See the pricing page for details.

Other stacks

HTMLJavaScriptReactReact NativeFlutterExpoMore examples →

Your Ionic form, live in minutes

Free forever on core features. No credit card required.

Create your form