HagenKit
Enterprise-ready Next.js boilerplate with authentication, database, payments, and beautiful UI components. Ship production-grade SaaS applications faster.
Install / Use
/learn @Codehagen/HagenKitREADME
Introduction
HagenKit is a batteries-included SaaS boilerplate that combines modern product design with production-ready infrastructure. Built on Next.js 16 and the App Router, it delivers authentication, multi-tenant workspaces, dashboards, and a marketing site so you can focus on customer value instead of scaffolding.
Highlights
- Multi-tenant SaaS foundations – Workspace model with owner/admin/member/viewer roles, invitations, and default workspace management.
- Authentication that scales – Better Auth with email/password, Google OAuth, session management, and client helpers for hydration-safe flows.
- Responsive UI system – Shadcn UI + Tailwind CSS components, marketing sections, and dashboard primitives tuned for accessibility.
- Email-ready out of the box – React Email templates and Resend integration for transactional messages.
- Developer velocity – TypeScript everywhere, server actions, data hooks, and deploy-ready configuration for Vercel.
Installation
Quick Start (Recommended)
If HagenKit is already deployed to Vercel, this is the fastest way to get started:
# 1. Clone the repository
git clone https://github.com/codehagen/hagenkit.git
cd hagenkit
# 2. Pull environment variables from Vercel
vercel env pull
# 3. Copy env file to project root
cp .vercel/.env.development.local .env
# 4. Install dependencies and sync database
pnpm hagenkit
That's it! Start the development server:
pnpm dev
Manual Setup
If you're setting up a new project from scratch:
git clone https://github.com/your-org/hagenkit.git
cd hagenkit
pnpm install
Copy the example environment file:
cp .env.example .env.local
Update .env.local with your credentials:
DATABASE_URLfor PostgreSQL (direct connection).BETTER_AUTH_SECRET,BETTER_AUTH_URL,NEXT_PUBLIC_APP_URL.- OAuth providers such as
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET. - Optional integrations (
RESEND_API_KEY, Stripe keys, etc.).
Generate the Prisma client and sync the schema:
pnpm prisma:generate
pnpm prisma:push
Start the development server with Turbopack:
pnpm dev
Useful Commands
pnpm hagenkit– install dependencies and sync database schema.pnpm dev– start development server with Turbopack.pnpm email– launch the React Email preview server.pnpm lint– run ESLint with the project config.
Magic Link Setup
HagenKit supports Magic Link authentication out of the box.
Development
For a seamless developer experience, if you do not provide a RESEND_API_KEY in your .env.local file while in development mode, emails will be logged to your terminal console.
- Go to the Sign In page.
- Enter your email and click "Sign in with Magic Link".
- Check your terminal where
pnpm devis running. - Click the link printed in the console to sign in.
Production
For production, you must set up Resend:
- Create an account at Resend.
- Get your API Key.
- Add
RESEND_API_KEYto your environment variables. - Verify your domain in Resend to ensure emails are delivered reliably.
🛡️ Security: First User Setup
Automatic Admin Assignment:
HagenKit automatically assigns the admin role to the first user who signs up. This ensures you have immediate access to the admin panel without any manual database manipulation.
- First Sign-Up: The first user created in the system will be granted the
adminrole. - Subsequent Users: All users signing up after the first one will be assigned the default
userrole.
No manual schema changes or migrations are required. The system handles this logic securely via database hooks.
Tech Stack + Features
Frameworks & Platforms
- Next.js 16 – App Router, Server Actions, and edge-ready rendering.
- Prisma ORM v7 + PostgreSQL – Type-safe ORM with
@prisma/adapter-pgdriver for direct TCP connections. Generated client inapp/generated/prisma. - Better Auth – Composable auth with cookie/session helpers and social providers.
- Vercel – First-class deployment target with optimized build output.
UI & UX
- Shadcn UI & Tailwind CSS – Component library with design tokens and Radix primitives.
- Framer Motion (via
motion) – Micro-interactions and animation choreography. - Lucide & Tabler Icons – Consistent iconography across marketing and product surfaces.
- Responsive marketing shell – Polished landing page in
app/(marketing)with reusable layout primitives.
Application Capabilities
- Dashboard modules – Team, analytics, lifecycle, and settings routes ready for data wiring.
- Workspace management – Invitations, member role updates, and ownership safeguards.
- Settings UI – Account, profile, and workspace panels using configurable data tables (
@tanstack/react-table). - Search & filtering utilities –
nuqsfor deep-linkable filters and stateful navigation. - Productivity hooks – Debounced callbacks, media queries, and mobile detection helpers.
Communications
- React Email templates in
emails/ready for transactional flows. - Resend integration glue for real email delivery.
Billing & Payments
- Polar Integration – Built-in support for payments via
@polar-sh/better-authplugin with automatic customer creation, checkout flows, and webhook handling. - Ready for Stripe – Extensible billing abstraction layer for future payment providers.
- Subscription Management – Customer portal, subscription status checks, and usage-based billing support.
- Billing Integration Guide – Complete setup instructions and configuration details.
Architecture
HagenKit separates concerns to keep features composable and scalable:
- App Router segmentation – Marketing
app/(marketing), auth flowsapp/(auth), admin areaapp/(admin), and the authenticated dashboard underapp/dashboard. - Server Actions – Business logic lives in
app/actions/*with typed inputs and output helpers (ActionResult). - Data Layer – Prisma schema models users, sessions, workspaces, invitations, and roles for robust multi-tenancy.
- Configuration – Centralized metadata in
lib/config.tspowers SEO, social cards, and upgrade CTAs. - UI System – Shared primitives in
components/ui, marketing layout helpers, and specialized dashboard/admin components.
Directory Structure
.
├── app
│ ├── (marketing) # Public marketing landing experience
│ ├── (auth) # Sign-in and sign-up flows
│ ├── (admin) # Admin panel entry
│ ├── dashboard # Authenticated product surface
│ ├── actions # Server actions for auth, workspaces, admin tools
│ └── generated/prisma # Generated Prisma client (keep in sync)
├── components
│ ├── ui # Shadcn-derived component library
│ ├── auth # Auth-specific views and helpers
│ ├── dashboard # Dashboard shell and empty states
│ ├── settings # Settings navigation, forms, tables
│ └── marketing # Landing page layout primitives
├── emails # React Email templates and preview entrypoint
├── hooks # Reusable client hooks (media queries, debounce, tables)
├── lib # Auth, config, utilities, and Prisma helpers
├── prisma # Database schema and migrations
└── public # Static assets (hero imagery, icons, og assets)
Contributing
We welcome contributions! To get involved:
- Open an issue for bugs, feature requests, or questions.
- Submit a pull request with clear scope, tests when applicable, and a concise changelog entry.
- Share feedback on developer experience, documentation, or onboarding.
Let's build production-grade SaaS products faster—together.
Related Skills
Writing Hookify Rules
99.2kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
review-duplication
99.9kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
feishu-drive
344.4k|
things-mac
344.4kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
