Sponsorkit for .NET

Install the Sponsorkit NuGet package and use it from console apps, CLIs, desktop apps and ASP.NET Core backends.

On this page

The Sponsorkit package tells your .NET app what the current user has contributed to your GitHub Sponsors and Open Collective accounts, and sends them to contribute. It's built for the places .NET code runs on a user's machine (console tools, dotnet global tools, and desktop apps such as WPF, WinForms or Avalonia), and it has a server-side helper for verifying supporters in ASP.NET Core or any other backend.

There's no Sponsorkit account or API key. You name the accounts you receive money on, and the SDK does the rest.

Requirements#

Target frameworkRuns onDependencies
net8.0.NET 8, 9, 10 and laterNone
netstandard2.0.NET Framework 4.6.2 or later, and other .NET Standard 2.0 runtimesSystem.Text.Json

NuGet picks the right build for your project. The public API is the same on both. The few runtime differences are listed in platform notes.

Install#

Sponsorkit is on NuGet. Add it the usual way:

dotnet add package Sponsorkit

The File-based app tab is for single-file apps run with dotnet run app.cs (.NET 10 and later). Every type lives in the Sponsorkit namespace.

A first call#

Program.cs
using Sponsorkit;

var sk = new SponsorkitClient(new SponsorkitOptions
{
    GitHub = "octocat",               // your GitHub Sponsors login
    OpenCollective = "my-collective", // and/or your Open Collective slug
    AppName = "my-cli",               // shown on the consent screen
});

// Never throws because of the network. Signed out, it returns at once without a request.
var fc = await sk.GetFinancialContributionAsync();
Console.WriteLine(fc.SignedIn
    ? $"Active contributions: {fc.Active().Count}"
    : $"Not signed in. Support my-cli: {sk.CheckoutUrl()}");

The constructor only validates your configuration; it does no I/O. Create one client per target set and reuse it: instances are thread-safe, so a singleton (or services.AddSingleton(...)) works well.

In this section#

PageWhat it covers
QuickstartA complete CLI: check, login, sponsor and logout commands.
ConfigurationEvery SponsorkitOptions property with its default, and the environment variables.
Sign-inLoopback and paste-back sign-in, timeouts, cancellation and a second identity.
ContributionsGetFinancialContributionAsync, the result, the filter helpers and caching.
CheckoutCheckoutUrl for links and OpenCheckoutAsync to wait for a new contribution.
NagA polite "please support" message every N runs or N days.
TestingMock mode, presets, and test hooks for time, environment and storage.
Backend verificationSponsorkitServer.VerifySessionAsync in ASP.NET Core.
Errors & cancellationSponsorkitError, its codes, and how CancellationToken behaves per method.
Platform notesnetstandard2.0 vs net8.0, storage locations, browsers, SSH, threading, custom storage.

Every public type and member is listed in the generated .NET API reference.