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 framework | Runs on | Dependencies |
|---|---|---|
net8.0 | .NET 8, 9, 10 and later | None |
netstandard2.0 | .NET Framework 4.6.2 or later, and other .NET Standard 2.0 runtimes | System.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<ItemGroup>
<PackageReference Include="Sponsorkit" Version="1.0.0" />
</ItemGroup><!-- Directory.Packages.props -->
<ItemGroup>
<PackageVersion Include="Sponsorkit" Version="1.0.0" />
</ItemGroup>
<!-- your .csproj -->
<ItemGroup>
<PackageReference Include="Sponsorkit" />
</ItemGroup>dotnet paket add Sponsorkit --project src/MyApp/MyApp.csprojInstall-Package Sponsorkit#:package Sponsorkit@1.0.0The 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#
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#
| Page | What it covers |
|---|---|
| Quickstart | A complete CLI: check, login, sponsor and logout commands. |
| Configuration | Every SponsorkitOptions property with its default, and the environment variables. |
| Sign-in | Loopback and paste-back sign-in, timeouts, cancellation and a second identity. |
| Contributions | GetFinancialContributionAsync, the result, the filter helpers and caching. |
| Checkout | CheckoutUrl for links and OpenCheckoutAsync to wait for a new contribution. |
| Nag | A polite "please support" message every N runs or N days. |
| Testing | Mock mode, presets, and test hooks for time, environment and storage. |
| Backend verification | SponsorkitServer.VerifySessionAsync in ASP.NET Core. |
| Errors & cancellation | SponsorkitError, its codes, and how CancellationToken behaves per method. |
| Platform notes | netstandard2.0 vs net8.0, storage locations, browsers, SSH, threading, custom storage. |
Every public type and member is listed in the generated .NET API reference.