Package managers & CDNs

Every way to add a Sponsorkit SDK to a project, per language and package manager, including browser imports from a CDN.

On this page

Each section below covers one language. The commands assume a published release.

JavaScript / TypeScript#

One package, @sponsorkit/sdk, with no runtime dependencies. It ships ESM and CommonJS builds and its own TypeScript types, so there is no @types package to add. It is on npm.

npm install @sponsorkit/sdk

Import from the entry point that matches where your code runs:

Entry pointForSign-inStorage
@sponsorkit/sdkBrowsers (and any runtime in mock mode)Popup, redirect fallbacklocalStorage
@sponsorkit/sdk/nodeNode, Bun, Deno: CLIs and desktop appsLoopback, paste-backPer-user config directory
@sponsorkit/sdk/serverBackends and Cloudflare WorkersNone: verifySession() onlyNone
@sponsorkit/sdk/elementsPlain HTML pages<sponsorkit-button>, <sponsorkit-badge>localStorage

The node entry uses Node built-ins (node:http, node:fs, node:child_process), so under Deno it asks for network, environment, file and subprocess permissions. Deno can also import it without deno add: import { Sponsorkit } from "npm:@sponsorkit/sdk@1.0.0/node";.

Browsers without a bundler#

The browser entry points only import their own files, so a CDN that mirrors npm can serve them as native ES modules. Pin an exact version in the URL:

<script type="module">
  import { Sponsorkit } from "https://esm.sh/@sponsorkit/sdk@1.0.0";

  const sk = new Sponsorkit({ github: "octocat", openCollective: "my-collective" });
  const fc = await sk.getFinancialContribution();
  if (fc.active().length === 0) document.querySelector("#sponsor-banner").hidden = false;
  document.querySelector("#sign-in").onclick = () => sk.signIn(); // popup: call it from the click
</script>

The web components register themselves when their module loads:

index.html
<script type="module" src="https://cdn.jsdelivr.net/npm/@sponsorkit/sdk@1.0.0/dist/elements.js"></script>

<sponsorkit-button github="octocat" amount="500" frequency="monthly">Sponsor</sponsorkit-button>
<sponsorkit-badge github="octocat"></sponsorkit-badge>

With esm.sh, the same module is https://esm.sh/@sponsorkit/sdk@1.0.0/elements. CDNs only serve published versions.

.NET#

The Sponsorkit NuGet package targets netstandard2.0 and net8.0. On .NET 8 and later it has no dependencies; the netstandard2.0 build depends on System.Text.Json. It is on NuGet.

dotnet add package Sponsorkit

Everything lives in the Sponsorkit namespace; the client class is SponsorkitClient.

Python#

The sponsorkit distribution supports Python 3.10 and later and depends only on httpx. It ships type hints (py.typed). It is on PyPI.

python -m pip install sponsorkit

Sponsorkit is a library, so you never install it with pipx. Declare it as a dependency of your own tool; when your users run pipx install your-tool, it comes along. To try a script without creating a project, uv run --with sponsorkit python my_cli.py installs it into a throwaway environment.

Go#

The module path is github.com/ffMathy/sponsorkit/sdks/go and the package name is sponsorkit. It needs Go 1.23 or later (its go.mod says go 1.23) and uses only the standard library.

Terminal
go get github.com/ffMathy/sponsorkit/sdks/go
main.go
import sponsorkit "github.com/ffMathy/sponsorkit/sdks/go"

The alias is optional, since the package is already named sponsorkit, but it makes the import read clearly. Go fetches the module from GitHub through the module proxy, so there is no separate registry. Releases are tags named sdks/go/vX.Y.Z; see versions & pinning.

Rust#

The sponsorkit crate needs Rust 1.85 or later (it uses the 2024 edition) and a Tokio runtime. It is on crates.io.

cargo add sponsorkit
cargo add tokio --features macros,rt-multi-thread
  • Features. The crate has no Cargo features of its own, so there is nothing to turn on or off.
  • TLS. HTTPS goes through reqwest with rustls, so the crate doesn't link OpenSSL and needs no system libraries.
  • Tokio. The SDK uses Tokio for timers, the loopback listener and cancellation, and works on the current-thread and multi-thread runtimes. #[tokio::main] needs the macros feature, plus rt-multi-thread for the default multi-thread flavour.