Introduction
Welcome to the SaaS Box documentation. This is the place to get started with the boilerplate, understand the core architecture, explore the built-in features, and learn how to build your application faster than ever before.
What is SaaS Box?
SaaS Box is a production-ready, full-stack Next.js boilerplate that helps you build highly scalable web applications in record time. I built it to include the most complex features you need to launch a SaaS, embodying strict industry best practices and providing a rock-solid foundation for massive applications.
Instead of stitching together dozens of incompatible libraries, you get a meticulously integrated, unified stack where authentication, database schemas, storage, and billing all talk to each other seamlessly out of the box.
App Architecture
The Next.js codebase is organized as a single, highly cohesive application utilizing the App Router with native internationalization.
src/app/[locale]/
The core routing for your application. This handles landing pages, protected dashboards, authentication flows, and legal documents in multiple languages natively.
src/components/
Reusable UI elements built with Shadcn UI. It is divided strictly by domain, utilizing subfolders like landing, dashboard, and auth for precise organization.
src/lib/
Third-party service integrations. Here you will find the logic for Better-Auth configurations, Polar webhooks, Resend email clients, and Cloudflare R2 storage utilities.
src/db/
The absolute source of truth for your data. It controls your Drizzle ORM schemas, table relations, and the Neon Serverless PostgreSQL connection instance.
Features
SaaS Box comes packed with everything you need to build a modern product.
Marketing & Landing
- Responsive hero, features, and pricing sections
- Beautiful, performant animations powered by Motion
- Pre-built legal pages (Terms, Privacy)
- Dark mode and theme toggling out of the box
Authentication
- Powered by Better-Auth directly in your database
- Robust Email/Password and OAuth (Google, GitHub) flows
- Complete password reset implementations
- Role-based access control and Admin Dashboard
Database & ORM
- Drizzle ORM for extreme type safety and performance
- Neon Serverless PostgreSQL pre-configured
- Automated schema migrations and type generation
- Zero-downtime scaling architecture
Payments & Billing
- Polar.sh integration for subscriptions and one-time payments
- Secure webhook processing mapped to your database
- Customer billing portal natively integrated
- Client-side checkout redirection logic
Storage & Emails
- Cloudflare R2 integration for zero-egress file storage
- Pre-signed URLs for highly secure user uploads
- Resend API integrated for transactional emails
Internationalization (i18n)
- Multi-language support deeply rooted in Next.js middleware
- Language switcher and automatic routing
- Type-safe dictionary mapping
The Tech Stack
Every tool in this stack was carefully selected to provide maximum type safety, superior developer experience, and massive scaling potential.
Next.js
FrameworkNext.js 16 utilizing the App Router is the foundation of the boilerplate. It handles both the frontend UI via React Server Components and the backend API Route Handlers. This architecture allows you to fetch data securely on the server, eliminating massive client-side bundles and drastically improving SEO and perceived loading speeds.
Drizzle ORM & Neon
DatabaseDrizzle is a lightning-fast, headless ORM that perfectly mirrors SQL while guaranteeing end-to-end TypeScript safety. It is paired with Neon Tech, a serverless PostgreSQL database provider. This combination ensures your database scales to zero during low traffic to save costs, yet handles massive sudden spikes effortlessly without connection pooling errors.
Better-Auth
AuthenticationA modern, highly extensible authentication library. Unlike rigid third-party services, Better-Auth stores user data, sessions, and OAuth accounts directly inside your own Drizzle database. This gives you 100% data ownership and the flexibility to query user relations natively.
Polar
PaymentsA deeply integrated, modern platform for handling subscriptions, billing portals, and monetization. The boilerplate listens to Polar.sh webhooks natively to update database user tiers in real-time, ensuring seamless access control across your platform.
Tailwind CSS & Shadcn UI
StylingTailwind CSS enables utility-first styling directly in your markup. Shadcn UI provides beautifully designed, accessible, and completely customizable headless components. Rather than installing an opaque npm package, Shadcn components are copied directly into your codebase, granting you total control over their markup and styles.
Motion
AnimationsMotion handles all complex UI animations, scroll reveals, and micro-interactions on the landing page, providing a premium, native feel without crippling performance or bloating your bundles.
Cloudflare R2 & Resend
InfrastructureCloudflare R2 offers S3-compatible object storage with zero egress fees, making it the perfect and most cost-effective solution for handling user uploads. Resend provides the fastest, most reliable developer API for delivering crucial transactional emails like password resets.
Frequently Asked Questions
Common questions about the SaaS Box architecture and licensing.
Why should I use SaaS Box over piecing things together myself?
Building a production-ready SaaS involves dozens of hours wrestling with OAuth callbacks, webhook verification, and database migrations. I created SaaS Box to provide a pre-architected foundation where Better-Auth, Polar, and Drizzle already communicate perfectly, saving you weeks of unbillable setup time so you can focus entirely on your business logic.
Why do you use Polar instead of Stripe?
While Stripe is powerful, it can be overwhelmingly complex for modern software subscriptions. Polar is built specifically for developers and digital products. It offers a much cleaner API, built-in Merchant of Record (MoR) capabilities to handle global taxes automatically, and a beautifully simple checkout experience right out of the box.
Can I swap out the database or ORM?
SaaS Box uses Drizzle ORM, which is incredibly flexible. While I default to Neon Serverless PostgreSQL for its auto-scaling capabilities and low latency, you can easily point Drizzle to any PostgreSQL provider (like Supabase, Railway, or standard AWS RDS) by simply updating your connection string in the .env file.
Do I need to be a Next.js expert to use this?
You should have a foundational understanding of React and Next.js components. However, the codebase is highly opinionated and strictly typed with TypeScript. This structure acts as guardrails, naturally guiding you toward best practices and preventing common architectural mistakes as your application scales.
Do I get access to future updates?
Yes. Your commercial license includes lifetime access to the GitHub repository. Whenever I push updates, security patches, or entirely new features to the boilerplate, you can pull the latest changes directly into your local projects.