@givebear/connect
v0.1.0
Published
Official TypeScript client for the Givebear Connect API.
Maintainers
Readme
@givebear/connect
Official TypeScript client for the Givebear Connect API. Read an organization's donation data and collect donations on its behalf.
Works in Node 18+, Bun, Deno, edge runtimes, and browsers (no Node-only deps).
Install
npm install @givebear/connectRead data
import { GivebearConnect } from "@givebear/connect";
const gb = new GivebearConnect({ token: process.env.GIVEBEAR_TOKEN! });
// token is an org API key (gb_live_...) or an OAuth access token (gba_...).
const { data, next_cursor } = await gb.donations.list({ limit: 50 });
// Auto-paginate:
for await (const donation of gb.donations.listAll({ updated_since: "2026-01-01T00:00:00Z" })) {
console.log(donation.amount_cents, donation.donor_email);
}
const org = await gb.organization.get();Resources: donations, donors, payouts (.list / .get / .listAll),
campaigns, funds (.list / .listAll), and organization (.get).
Collect a donation
const intent = await gb.paymentIntents.create({
amount_cents: 5000,
fund_id: "general",
donor_email: "[email protected]",
donor_name: "Jane Doe",
});
// Render Stripe Elements with intent.client_secret + intent.publishable_key
// + intent.stripe_account_id. Card data goes straight to Stripe.Verify webhooks
import { verifyWebhook } from "@givebear/connect";
const event = await verifyWebhook({
secret: process.env.GIVEBEAR_WEBHOOK_SECRET!,
signature: req.headers["x-givebear-signature"] as string,
body: rawBody, // the raw request body string, not re-serialized
});
// event.type, event.data.id -> fetch the full record:
const donation = await gb.donations.get(event.data.id);Throws WebhookVerificationError on a bad signature or stale timestamp, and
ConnectApiError (with .status and .type) on API errors.
Links
- Quickstart
- API reference
- Full example app (OAuth, read API, live webhooks)
License
MIT
