Send form submissions to Formclick from .NET MAUI apps on Android, iOS, macOS and Windows. It also works in Xamarin, Blazor, WPF, console apps, or anything else on .NET 6 or later.
It has the same API as @formclick/react-native and the formclick Flutter package: a thread-safe FormclickClient, plus a FormclickSubmitter that implements INotifyPropertyChanged, so you can bind loading, success and error state straight from XAML. There are no dependencies beyond the .NET base library.
dotnet add package FormclickGet your access key from the Formclick dashboard. Every example below uses YOUR_ACCESS_KEY.
// ContactViewModel.cs
using System.Windows.Input;
using Formclick;
public class ContactViewModel
{
public FormclickSubmitter Form { get; } = new();
public string Name { get; set; } = "";
public string Email { get; set; } = "";
public ICommand SendCommand { get; }
public ContactViewModel()
{
SendCommand = new Command(async () =>
{
try
{
await Form.SubmitAsync("YOUR_ACCESS_KEY", new Dictionary<string, object?>
{
["name"] = Name,
["email"] = Email,
});
}
catch (FormclickException) { /* shown via Form.ErrorMessage */ }
});
}
}<!-- ContactPage.xaml -->
<VerticalStackLayout Padding="16" Spacing="12">
<Entry Placeholder="Name" Text="{Binding Name}" />
<Entry Placeholder="Email" Keyboard="Email" Text="{Binding Email}" />
<Button Text="Send" Command="{Binding SendCommand}"
IsEnabled="{Binding Form.IsLoading, Converter={StaticResource InvertedBoolConverter}}" />
<ActivityIndicator IsRunning="{Binding Form.IsLoading}" />
<Label Text="Sent!" TextColor="Green" IsVisible="{Binding Form.IsSuccess}" />
<Label Text="{Binding Form.ErrorMessage}" TextColor="Red" />
</VerticalStackLayout>InvertedBoolConverter comes from the .NET MAUI Community Toolkit. You can also bind to a property on your own view model instead.
// MauiProgram.cs
builder.Services.AddSingleton(new FormclickClient());
builder.Services.AddTransient<FormclickSubmitter>();using Formclick;
var result = await new FormclickClient().SubmitAsync("YOUR_ACCESS_KEY", new Dictionary<string, object?>
{
["name"] = "Jane",
["email"] = "jane@example.com",
["topics"] = new[] { "billing" },
});
Console.WriteLine($"{result.Success} {result.Message}");Field values can be strings, numbers, booleans, null or arrays.
Every failure throws a FormclickException. Its Status holds the HTTP status code for server errors, and is null for a missing access key or a network failure. Message contains the server's message, for example [Formclick] Invalid access key.
var client = new FormclickClient(
submitBaseUrl: "https://api.formclick.io/submit", // default
headers: new Dictionary<string, string> { ["X-App-Version"] = "1.2.0" },
httpClient: new HttpClient { Timeout = TimeSpan.FromSeconds(30) } // optional
);
var form = new FormclickSubmitter(client);
form.Succeeded += result => Debug.WriteLine($"Sent: {result.Message}");
form.Failed += error => Debug.WriteLine($"Failed: {error.Message}");dotnet test # uses a fake HttpMessageHandler, no network calls
dotnet pack src/Formclick -c ReleaseMIT © Formclick