A simple dashboard example demonstrating how to use @onlyfansapi/auth with Next.js and Prisma to manage OnlyFans accounts.
- 🔐 Connect OnlyFans accounts using
@onlyfansapi/auth - 💾 Store account data in PostgreSQL via Prisma
- 📊 Simple dashboard to view and manage accounts
- 🎨 Modern, responsive UI with Tailwind CSS
- 🔑 Secure API key handling (server-side only)
- Node.js 18+ or Bun
- PostgreSQL database
- OnlyFans API key from onlyfansapi.com
git clone <this-repo>
cd auth-example-nextjs-prisma
bun install
# or
npm installCreate a .env file in the root directory:
# Database connection string (required)
DATABASE_URL="postgresql://user:password@localhost:5432/mydb?sslmode=verify-full"
# OnlyFans API Key (get it from https://app.onlyfansapi.com/api-keys)
# This stays server-side and is never exposed to the client
OFAPI_API_KEY="ofapi_..."Push the schema to your database:
bun run db:push
# or
npm run db:pushbun dev
# or
npm run devOpen http://localhost:3000 to view the dashboard.
- User clicks "Add Account" → Modal prompts for a display name
- Backend creates client session →
POST /api/client-sessioncalls the OnlyFans API to create a temporary client session token - Auth popup opens →
startOnlyFansAuthentication()uses the token to open a secure authentication popup - Account saved → On success, account details are saved to the database
This flow ensures your API key stays secure on the server and is never exposed to the client.
├── app/
│ ├── api/
│ │ ├── accounts/
│ │ │ ├── route.ts # GET/POST accounts
│ │ │ └── [id]/route.ts # DELETE account
│ │ └── client-session/
│ │ └── route.ts # Create client session token
│ ├── generated/prisma/ # Generated Prisma client
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Dashboard page
├── lib/
│ └── prisma.ts # Prisma client instance
├── prisma/
│ └── schema.prisma # Database schema
└── ...
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/accounts |
List all accounts |
POST |
/api/accounts |
Add a new account |
DELETE |
/api/accounts/[id] |
Delete an account |
POST |
/api/client-session |
Create a client session token |
| Script | Description |
|---|---|
bun dev |
Start development server |
bun run build |
Build for production |
bun run db:push |
Push schema to database |
bun run db:studio |
Open Prisma Studio |
- Next.js 16 - React framework
- Prisma 7 - Database ORM with driver adapters
- Tailwind CSS 4 - Styling
- @onlyfansapi/auth - OnlyFans authentication
model Account {
id String @id @default(cuid())
accountId String @unique // OnlyFans account ID
username String // OnlyFans username
displayName String // User-entered display name (shown in dashboard)
name String? // OnlyFans profile name
avatar String? // Avatar URL
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}- The
OFAPI_API_KEYis only used server-side and never sent to the browser - Client session tokens are temporary and scoped to a single authentication attempt
- No authentication is implemented for this dashboard (it's an example repo)
MIT