{"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,"search_vec":"'1.4.0':52 'adapt':46 'affili':3,6,16,57 'auth':2,13,44,51,56,61 'better':1,12,43,50,55 'better-auth':49,54 'built':36 'click':18 'commiss':20,27,59 'complet':5 'compon':39 'dashboard':38 'databas':45 'enabl':15 'integr':24 'javascript':53 'link':17 'manag':21 'plugin':10,62 'pre':35 'pre-built':34 'react':37 'recur':26 'referr':8,58 'requir':48 'ship':28 'stripe':23,60 'system':9 'track':19 'type':30 'typescript':29,63 'v0.1.0':14 'valid':32 'work':40 'zod':31","created_at":"2026-05-09T05:51:10.062523+00:00","updated_at":"2026-05-09T05:51:10.062523+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/ericc59/better-auth-affiliates","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/better-auth-affiliates","openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","payments","database","web-framework","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-09","next_check":"2026-08-07","install_tag":null}}