@faurya/affiliate
v0.2.0
Published
Free React and Next.js affiliate dashboard components for Faurya users with referral links and commission helpers.
Readme
Faurya Affiliate
React components and server helpers for building affiliate dashboards with Faurya data.
@faurya/affiliate provides dashboard UI, referral-link helpers, lightweight auth helpers, commission display utilities, and Next.js App Router adapters. It is source-available and free to use for Faurya users.
Your application remains responsible for affiliate records, attribution rules, billing events, approvals, accounting, disputes, and payouts. Faurya is primarily an analytics and attribution platform; this package does not operate an affiliate program or payment service for you.
Install
For Next.js projects, the setup command is the fastest path:
npx @faurya/affiliate setup --email [email protected]The command creates /affiliate/login, /affiliate/signup, /affiliate/dashboard, /api/auth/* route handlers, and required .env.local values.
Useful options:
npx @faurya/affiliate setup --email [email protected] --brand "Acme Partners"
npx @faurya/affiliate setup --email [email protected] --skip-install
npx @faurya/affiliate setup --email [email protected] --forceManual install:
npm install @faurya/affiliate react react-domInstall next only when using the Next.js adapters.
Environment
Minimum fixed-invite configuration:
[email protected]
FIXED_USER_PASSWORD_HASH=scrypt\$...
MAGIC_LINK_SECRET=change-me-to-a-random-secret-at-least-32-bytes-long
SESSION_SECRET=change-me-to-a-random-secret-at-least-32-bytes-long
APP_URL=https://your-app.com
AUTH_REDIRECT_PATH=/dashboard
AFFILIATE_REFERRAL_SECRET=change-me-to-a-random-secret-at-least-32-bytes-longOptional public signup:
AFFILIATE_PUBLIC_SIGNUP_ENABLED=true
AFFILIATE_SIGNUP_SECRET=change-me-to-a-random-secret-at-least-32-bytes-long
AFFILIATE_ONBOARDING_FORM_URL=https://forms.example.com/affiliate-onboardingOptional Cloudflare Turnstile protection for auth forms:
AFFILIATE_TURNSTILE_ENABLED=true
AFFILIATE_TURNSTILE_SITE_KEY=0x4AAAA...
AFFILIATE_TURNSTILE_SECRET_KEY=0x4AAAA...Turnstile is enabled automatically when both keys are set. Set AFFILIATE_TURNSTILE_ENABLED=false to turn it off without removing keys.
Optional Redis-backed rate limiting for auth routes:
AFFILIATE_RATE_LIMIT_ENABLED=true
AFFILIATE_RATE_LIMIT_REDIS_URI=rediss://default:password@host:6379/0
AFFILIATE_RATE_LIMIT_MAX_REQUESTS=3
AFFILIATE_RATE_LIMIT_WINDOW_MS=60000Rate limiting is optional and only active when AFFILIATE_RATE_LIMIT_REDIS_URI is set. Defaults are tight: 3 attempts per minute. Set AFFILIATE_RATE_LIMIT_ENABLED=false to turn it off without removing the URI. REDIS_URL is also accepted as an alias.
Optional Faurya API integration:
FAURYA_API_KEY=your-faurya-api-key
FAURYA_API_BASE_URL=https://api.faurya.comKeep secrets and password hashes server-only. In Next.js .env files, escape $ in scrypt hashes as \$.
Quick example
import { AffiliateDashboard } from '@faurya/affiliate';
export function PartnerDashboard({ visitor }: { visitor: any }) {
return (
<AffiliateDashboard
brandName="Acme Partners"
userEmail="[email protected]"
visitor={visitor}
theme={{ primary: '#2563eb', radius: 20 }}
/>
);
}Package exports
| Import | Use |
| --- | --- |
| @faurya/affiliate | Browser-safe React components. |
| @faurya/affiliate/react | Same React components. |
| @faurya/affiliate/server | Server-only auth, API, referral, and commission helpers. |
| @faurya/affiliate/next | Next.js route handlers. |
Do not import server or Next.js helpers from client components.
Features
- Embeddable affiliate dashboard and login components.
- Custom branding, labels, themes, metrics, charts, and render hooks.
- Referral-link generation with optional HMAC signatures.
- Display-only commission calculations using integer cents and basis points.
- Server-only Faurya visitor API client.
- Optional fixed-user password, magic-link, and public-signup auth helpers.
- Next.js App Router route-handler adapters.
What is not included
This package does not create a database, process payouts, store paid/unpaid status, replace your app's user system, or expose server secrets to the browser.
Site owners are responsible for their own affiliate terms, payment decisions, taxes, refunds, fraud review, data backups, security, and disputes with affiliates or users. Displayed commission values are informational until approved by the site owner.
Documentation
Development
npm install
npm run devBefore publishing:
npm test
npm run typecheck
npm run build
npm run build:example
npm pack --dry-runLicense and terms
This package is free to use and build on for Faurya users, subject to the license and terms.
It may not be used to clone Faurya, replicate this package as a standalone affiliate SaaS, or build a competing analytics, attribution, referral-tracking, affiliate-dashboard, or affiliate-SaaS product.
