{"id":27613,"library":"better-auth-affiliates","title":"Better Auth Affiliates","description":"A complete affiliate and referral system plugin for Better Auth v0.1.0, enabling affiliate links, click tracking, commission management, and Stripe integration with recurring commissions. Ships TypeScript types, Zod validation, and pre-built React dashboard components. Works with any Better Auth database adapter and requires better-auth >= 1.4.0.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/ericc59/better-auth-affiliates","tags":["javascript","better-auth","affiliate","referral","commission","stripe","auth","plugin","typescript"],"install":[{"cmd":"npm install better-auth-affiliates","lang":"bash","label":"npm"},{"cmd":"yarn add better-auth-affiliates","lang":"bash","label":"yarn"},{"cmd":"pnpm add better-auth-affiliates","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin integration","package":"better-auth","optional":false}],"imports":[{"note":"Named export, not default. Only works with Better Auth >=1.4.0.","wrong":"import affiliatePlugin from 'better-auth-affiliates'","symbol":"affiliatePlugin","correct":"import { affiliatePlugin } from 'better-auth-affiliates'"},{"note":"Client plugin is in a subpath export '/client' – importing from main path will give undefined.","wrong":"import { affiliateClientPlugin } from 'better-auth-affiliates'","symbol":"affiliateClientPlugin","correct":"import { affiliateClientPlugin } from 'better-auth-affiliates/client'"},{"note":"Named export containing helper functions for Stripe integration.","wrong":"import stripeIntegration from 'better-auth-affiliates'","symbol":"stripeIntegration","correct":"import { stripeIntegration } from 'better-auth-affiliates'"}],"quickstart":{"code":"// auth.ts\nimport { betterAuth } from 'better-auth'\nimport { affiliatePlugin } from 'better-auth-affiliates'\n\nexport const auth = betterAuth({\n  plugins: [\n    affiliatePlugin({\n      commissionRate: '30.00',\n      commissionType: 'percentage',\n      commissionDurationMonths: 12,\n      cookieDurationDays: 30,\n    }),\n  ],\n})\n\n// auth-client.ts\nimport { createAuthClient } from 'better-auth/client'\nimport { affiliateClientPlugin } from 'better-auth-affiliates/client'\n\nexport const authClient = createAuthClient({\n  plugins: [affiliateClientPlugin()],\n})\n\n// Track click on landing page\nconst code = new URLSearchParams(window.location.search).get('ref')\nif (code) {\n  await authClient.affiliate.trackClick({ code })\n}","lang":"typescript","description":"Sets up affiliate plugin with Better Auth, client plugin, and click tracking with URL ref parameter."},"warnings":[{"fix":"Use import { affiliateClientPlugin } from 'better-auth-affiliates/client'","message":"Client plugin must be imported from 'better-auth-affiliates/client', not the main package","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Update better-auth to >=1.4.0","message":"Requires better-auth >=1.4.0. Older versions will not work.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Use string format for commissionRate (e.g., '30.00')","message":"Commission rate is a string like '30.00', not a number. Passing a number will cause runtime errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install the package: npm install better-auth-affiliates, and import from 'better-auth-affiliates/client'","cause":"Client plugin imported from wrong path or package not installed.","error":"Cannot find module 'better-auth-affiliates/client' or its corresponding type declarations."},{"fix":"Change import to: import { affiliateClientPlugin } from 'better-auth-affiliates/client'","cause":"Client plugin imported from main package instead of '/client'.","error":"affiliateClientPlugin is not a function"},{"fix":"Use a string like '30.00' for commissionRate.","cause":"Providing a number for commissionRate instead of string.","error":"Type 'number' is not assignable to type 'string'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}