Skip to content

About

.NET SDK for Formclick. Send form submissions from MAUI, Xamarin, Blazor and any .NET app, with MVVM-ready bindable state. No backend needed.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Formclick for .NET (MAUI)

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.

Installation

dotnet add package Formclick

Get your access key from the Formclick dashboard. Every example below uses YOUR_ACCESS_KEY.

MAUI with MVVM

// 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.

Dependency injection

// MauiProgram.cs
builder.Services.AddSingleton(new FormclickClient());
builder.Services.AddTransient<FormclickSubmitter>();

One-shot call

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.

Errors

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.

Configuration

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}");

Development

dotnet test   # uses a fake HttpMessageHandler, no network calls
dotnet pack src/Formclick -c Release

License

MIT © Formclick

About

.NET SDK for Formclick. Send form submissions from MAUI, Xamarin, Blazor and any .NET app, with MVVM-ready bindable state. No backend needed.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages