Send form submissions to Formclick from React Native and Expo apps.
It has a useFormclick() hook that tracks loading, success and error state, and an optional FormclickProvider for shared configuration. It uses React Native's built-in fetch and has no native code, so it works in Expo Go.
npm install @formclick/react-nativeGet your access key from the Formclick dashboard. Every example below uses YOUR_ACCESS_KEY.
import { useState } from 'react';
import { ActivityIndicator, Button, Text, TextInput, View } from 'react-native';
import { useFormclick } from '@formclick/react-native';
export function ContactForm() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const { submit, loading, success, error } = useFormclick();
const send = () =>
submit({ formId: 'YOUR_ACCESS_KEY', data: { name, email } }).catch(() => {});
return (
<View style={{ gap: 12, padding: 16 }}>
<TextInput placeholder="Name" value={name} onChangeText={setName} />
<TextInput placeholder="Email" value={email} onChangeText={setEmail}
keyboardType="email-address" autoCapitalize="none" />
{loading ? <ActivityIndicator /> : <Button title="Send" onPress={send} />}
{success && <Text style={{ color: 'green' }}>Sent!</Text>}
{error && <Text style={{ color: 'red' }}>{error.message}</Text>}
</View>
);
}const { submit } = useFormclick({
onSuccess: () => Alert.alert('Sent!'),
onError: (err) => Alert.alert('Error', err.message),
});import { FormclickProvider } from '@formclick/react-native';
<FormclickProvider
submitBaseUrl="https://api.formclick.io/submit"
headers={{ 'X-App-Version': '1.2.0' }}
onError={(err) => console.warn(err)}
>
<App />
</FormclickProvider>| Returns | Type | Description |
|---|---|---|
submit(options) |
(SubmitOptions) => Promise<SubmitResult> |
Sends a submission. Rejects on error |
loading |
boolean |
true while a request is in flight |
success |
boolean |
true after a successful submission |
error |
Error | null |
The last error |
data |
SubmitResult | null |
The last successful response |
reset() |
() => void |
Resets state to idle |
| Property | Type | Description |
|---|---|---|
formId |
string |
Your Formclick access key |
data |
FormValues |
Field values to submit |
submitUrl |
string? |
Overrides the full endpoint URL |
pnpm install
pnpm typecheck
pnpm buildMIT © Formclick