{"id":13810440,"url":"https://github.com/airbadge-dev/airbadge","last_synced_at":"2025-05-14T10:33:26.845Z","repository":{"id":225960313,"uuid":"750352241","full_name":"airbadge-dev/airbadge","owner":"airbadge-dev","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-06T18:02:20.000Z","size":1320,"stargazers_count":125,"open_issues_count":2,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-11-19T03:43:06.619Z","etag":null,"topics":["authjs","identity","oauth","payments","saas","stripe"],"latest_commit_sha":null,"homepage":"https://docs.airbadge.dev","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/airbadge-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-30T13:39:10.000Z","updated_at":"2024-10-10T14:47:59.000Z","dependencies_parsed_at":"2024-03-05T07:42:15.859Z","dependency_job_id":"f3e31a7e-123f-41fe-b521-a6a99202cb53","html_url":"https://github.com/airbadge-dev/airbadge","commit_stats":null,"previous_names":["joshnuss/airbadge","airbadge-dev/airbadge"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbadge-dev%2Fairbadge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbadge-dev%2Fairbadge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbadge-dev%2Fairbadge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbadge-dev%2Fairbadge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airbadge-dev","download_url":"https://codeload.github.com/airbadge-dev/airbadge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254121149,"owners_count":22018114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authjs","identity","oauth","payments","saas","stripe"],"created_at":"2024-08-04T02:00:53.789Z","updated_at":"2025-05-14T10:33:24.909Z","avatar_url":"https://github.com/airbadge-dev.png","language":"Svelte","funding_links":[],"categories":["Svelte"],"sub_categories":[],"readme":"\u003cimg src=\"logo.svg\" alt=\"logo\" width=\"800\"/\u003e\n\n\u003e Stripe + Auth.js + SvelteKit\n\nThis project provides an easy way to create a SaaS site.\n\nIt is a [Stripe](https://stripe.com) addon for [Auth.js](https://authjs.dev).\n\nLaunch a SaaS app without writing any authentiction or payment code!\n\n## Features\n\n- **Integrated Payment**: Stripe Checkout is built into the signup flow.\n- **Authentication**: Over 50 OAuth options (Google, Apple, GitHub...), provided by Auth.js.\n- **Gating**: Access to routes and components can be restricted based on subscription.\n- **Self-service account management**: Changing or canceling plans is accessible via `/billing/portal`.\n- **Webhook handling**: All Stripe webhooks are handled for you.\n- **Trials \u0026 Free plans**: Checkout can be skipped for free plans or trials.\n- **Session data**: Subscription and plan data is included in the session.\n- **Open source**: https://github.com/airbadge-dev/airbadge\n- **BSL Licence**: Free to use. With optional [paid features](https://docs.airbadge.dev/license#paid-features).\n\n## Gating\n\nThe session data contains info about the user's subscription \u0026 purchase history, so it's easy to gate routes and components in your app.\n\n### Gating Routes\n\nTo gate routes, check the `session.subscription` or `session.purchases` for authorization:\n\n```javascript\nexport async function load({ locals }) {\n  const session = await locals.getSession()\n\n  // for a subscription, check session.subscription\n  if (session?.subscription?.plan != 'pro') {\n    error(401, 'Must be on pro plan')\n  }\n\n  // alternatively, for one-time purchases, check session.purchases\n  if (session?.purchases.includes('e-book')) {\n    error(401, 'Please purchase the e-book to continue')\n  }\n\n\n  // do the gated thing here\n}\n```\n\n### Components\n\nGating components is similar to gating routes. The same `session.subscription` \u0026 `session.purchases` data is available.\n\n```svelte\n\u003cscript\u003e\n  export let data\n\u003c/script\u003e\n\n{#if data.session?.subscription?.plan == 'pro'}\n  Your on the PRO plan!\n{/if}\n\n{#if data.session?.purchases.includes('e-book')}\n  \u003ca href=\"/download\"\u003eDownload e-book\u003c/a\u003e\n{/if}\n```\n\n## Billing Endpoint\n\nThis package provides a `/billing` endpoint, similar to how Auth.js provides a `/auth` endpoint.\n\nThe following routes are provided:\n\n- `/billing/checkout`: Redirect current user to a Stripe checkout session.\n- `/billing/portal`: Opens the billing portal for the current signed-in user.\n- `/billing/cancel`: Cancels the current user's subscription.\n- `/billing/webhooks`: Handles all Stripe webhooks for you.\n- `/billing/modify`: Modify the current user's billing plan.\n- `/billing/checkout/complete`: Handles post-checkout housekeeping.\n\n## Setup\n\nInstall [@airbadge/sveltekit](https://npmjs.com/package/@airbadge/sveltekit):\n\n```sh\npnpm i -D @airbadge/sveltekit\n```\n\nSetup a database provider for Auth.js. For example, follow instructions for Prisma:\n\nhttps://authjs.dev/reference/adapter/prisma\n\nAdd environment variables to `.env`:\n\n```sh\nPUBLIC_STRIPE_KEY=pk_...\nSECRET_STRIPE_KEY=sk_...\nDOMAIN=http://localhost:5173\nDATABASE_URL=\"postgresql://postgres:postgres@localhost:5432/auth_stripe_sveltekit_dev?schema=public\"\nAUTH_GITHUB_ID=\nAUTH_GITHUB_SECRET=\n```\n\nConfigure authentication and billing options in `src/hooks.server.js`:\n\n```javascript\nimport { SvelteKitAuth } from '@airbadge/sveltekit'\n\n// use any OAuth provider (or multiple)\nimport GitHub from '@auth/sveltekit/providers/github'\n\n// import prisma client for Auth.js's database adapter\nimport { PrismaClient } from '@prisma/client'\n\n// init database client\nconst db = new PrismaClient()\n\n// add Auth.js + Stripe handler\n// API is similar to Auth.js\nexport const { handle } = SvelteKitAuth({\n  // configure database adapter\n  adapter: PrismaAdapter(db),\n\n  // configure OAuth providers\n  providers: [ GitHub ]\n})\n```\n\nForward Stripe events to `localhost`:\n\n```sh\nstripe listen --forward-to localhost:5173/billing/webhooks\n```\n\n## License\n\nBSL - Business Software License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbadge-dev%2Fairbadge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairbadge-dev%2Fairbadge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbadge-dev%2Fairbadge/lists"}