Documentation
Documentation
Introduction

Getting Started

Getting StartedInstallationQuick StartProject Structure

Architecture

Architecture OverviewTech StacktRPC MiddlewareDesign Principles

Patterns

Code Patterns & ConventionsFeature ModulesError HandlingType Safety

Database

DatabaseSchema DefinitionDatabase OperationsMigrationsCaching

API

tRPCProceduresRouterstRPC Proxy Setup
APIsOpenAPIREST Endpoints

Auth & Access

AuthenticationConfigurationOAuth ProvidersRolesSession Management
AuthorizationUser RolesPermissions

Routing & i18n

RoutingDeclarative RoutingNavigation
InternationalizationTranslationsLocale Routing

Components & UI

ComponentsButtonsFormsNavigationDialogs
StylesTailwind CSSThemingTypography

Storage

StorageConfigurationUsageBuckets

Configuration

ConfigurationEnvironment VariablesFeature Flags

Templates

Template GuidesCreate New FeatureCreate New PageCreate Database TableCreate tRPC RouterAdd Translations

Development

DevelopmentCommandsAI AgentsBest Practices

Introduction

Welcome to the Next.js SaaS Template documentation

Welcome

This is a production-ready Next.js SaaS template built with modern best practices, extensive AI/agent support, and a focus on developer experience. The template emphasizes type safety, feature-based architecture, and clean code patterns.

What's Included

Everything you need to build a modern SaaS application:

  • Feature-Based Architecture - Organized 5-file pattern for scalable modules
  • Type-Safe APIs - tRPC with full-stack TypeScript
  • Database - PostgreSQL with Drizzle ORM, caching, and RLS
  • Authentication - Better-Auth with OAuth and role-based access
  • Internationalization - next-intl with declarative routing
  • UI Components - Shadcn UI with Tailwind CSS
  • Error Handling - Comprehensive error translation system
  • File Storage - Firebase/S3 integration
  • AI Agent Support - Configurations for Claude, Cursor, Copilot, and more

Quick Links

  • Getting Started - Installation and setup
  • Architecture - Understand the tech stack and design
  • Patterns - Learn code conventions and best practices
  • Templates - Step-by-step guides for common tasks
  • Development - Commands, workflows, and AI agents

Tech Stack

CategoryTechnology
FrameworkNext.js 16+ (App Router)
LanguageTypeScript
DatabasePostgreSQL + Drizzle ORM
APItRPC
AuthenticationBetter-Auth
UIShadcn UI + Tailwind CSS
FormsReact Hook Form + Zod
StateReact Query (via tRPC)
i18nnext-intl

Documentation Structure

This documentation is organized into focused sections:

Core Concepts

  • Architecture - Tech stack, middleware, and design principles
  • Patterns - Feature modules, error handling, and type safety
  • Database - Schema, operations, migrations, and RLS
  • API - tRPC procedures, OpenAPI, and rate limiting

Development

  • Templates - Step-by-step guides for creating features, pages, and tables
  • Development - Commands, AI agent setup, and workflows
  • Configuration - Environment variables and app settings

Frontend

  • Routing & i18n - Declarative routing and translations
  • Components & UI - Icons, typography, forms, and styling
  • Auth & Access - Authentication flows and authorization

Key Principles

This template follows strict conventions:

  1. Always use type not interface
  2. Use double quotes for strings
  3. Feature-based organization - 5-file pattern for all features
  4. Type safety first - Zod schemas and TypeScript everywhere
  5. Component standards - <Icon>, <H1>-<H6>, <Section> components
  6. Error handling - ActionResponse pattern with translations
  7. No arbitrary values - Use design tokens from config

See Patterns for the complete list of conventions.

On this page

Welcome
What's Included
Quick Links
Tech Stack
Documentation Structure
Core Concepts
Development
Frontend
Key Principles