I’ve built the same Django + Next.js boilerplate 47 times. Authentication, Docker, TypeScript, API endpoints, deployment scripts. Over and over.
Last month I finally snapped and built an open source starter template that includes everything. Plus seven Claude Code agents that actually understand your codebase.
This Django Next.js tutorial shows you how to bootstrap a full-stack SaaS app in 2025.
Table of contents
Open Table of contents
Why Another Django Next.js Boilerplate?
I tried several Django Next.js starter templates and cookiecutters on the internet. Most boilerplates fall apart when you need:
- Background jobs
- Proper error handling
- Production deployments
- AI coding assistance (big one)
- Fast package management
This Django Next.js starter template is different. It’s what I actually use to ship production SaaS apps. I’ll admit it’s fairly opinionated but it works great for me. Hope it’s useful to you too.
Key features of this open source boilerplate:
- Complete Django + Next.js scaffold ready for 2025
- AI-powered development with Claude Code agents
- Docker setup for instant development
- Production-ready structure (not a toy example)
The Stack That Actually Ships
- Backend: Django 5.1 + Django Ninja (FastAPI-style endpoints)
- Frontend: Next.js 15 + TypeScript + Tailwind CSS + shadcn/ui
- AI Integration: Claude Code agents + CLAUDE.md files
- Package Management: uv (100x faster than pip)
- Everything Else: Docker, pre-commit hooks, GitHub Actions
Django Next.js Example: From Zero to Running App
1. Clone and Setup
# Clone the template
gh repo create my-ai-app --template code-geek/ai-project-template --public
cd my-ai-app
# Run the setup script (installs everything)
./scripts/setup-dev.sh
That’s it. The setup script:
- Installs uv if needed
- Sets up Python environment
- Installs npm packages
- Configures pre-commit hooks
- Copies .env files
2. Start Development
# Using Docker (recommended)
docker-compose up
# Or run separately
cd backend && uv run python manage.py runserver
cd frontend && npm run dev
Your app is now running:
- Frontend: http://localhost:3000
- API Docs: http://localhost:8000/api/docs
3. See It Work
The template includes a working example API. Try it:
# Health check
curl http://localhost:8000/api/health
# Example endpoint
curl http://localhost:8000/api/example/hello/world
Why This Template Is Different
1. AI-Optimized from Day One
Every file has purpose-built instructions for Claude:
# backend/CLAUDE.md
- Models live in `apps/*/models.py`
- API endpoints use Django Ninja in `apps/*/api.py`
- Business logic goes in `apps/*/services.py`
- Always run tests after changes
2. Specialized AI Agents
Seven Claude agents that activate automatically:
- code-reviewer: Reviews your PRs for security and quality
- test-writer: Generates comprehensive test suites
- backend-architect: Designs Django REST APIs
- frontend-engineer: Builds React components
- debugger: Systematically fixes errors
- performance-optimizer: Makes your code faster
- api-designer: Creates RESTful specifications
Example: Just ask “review this code” and the code-reviewer agent activates.
3. Production-Structured, Not a Toy
# docker-compose.yml includes:
- PostgreSQL 16 with health checks
- Redis for caching
- Celery infrastructure included (configuration coming soon)
- Proper networking and volumes
4. Modern Python with uv
Forget pip. Forget poetry. Forget waiting.
# Old way (30 seconds)
pip install django djangorestframework pytest ...
# New way (0.3 seconds)
uv sync
Your CI builds just got 10x faster.
5. Django Ninja > Django REST Framework
Django Ninja gives you FastAPI-style development with Django’s stability:
# Django REST Framework way (verbose)
class TaskSerializer(serializers.ModelSerializer):
class Meta:
model = Task
fields = ['id', 'title', 'completed']
class TaskViewSet(viewsets.ModelViewSet):
queryset = Task.objects.all()
serializer_class = TaskSerializer
# Django Ninja way (clean)
@router.get("/tasks", response=List[TaskSchema])
def list_tasks(request):
return Task.objects.all()
Django Ninja provides FastAPI-style development with Django’s stability. It offers high performance through Pydantic and async support, with automatic OpenAPI docs and type hints built-in.
Django Next.js Tutorial: Build Your First Feature
Let’s add a simple task tracker API:
1. Create the Model
# backend/apps/tasks/models.py
from django.db import models
class Task(models.Model):
title = models.CharField(max_length=200)
completed = models.BooleanField(default=False)
created = models.DateTimeField(auto_now_add=True)
2. Add the API Endpoint
# backend/apps/tasks/api.py
from ninja import Router
from .models import Task
router = Router()
@router.get("/tasks")
def list_tasks(request):
return list(Task.objects.values())
@router.post("/tasks")
def create_task(request, title: str):
task = Task.objects.create(title=title)
return {"id": task.id, "title": task.title}
3. Frontend Component
// frontend/src/components/features/TaskList.tsx
export function TaskList() {
const { data: tasks } = useSWR('/api/tasks')
return (
<div className="space-y-2">
{tasks?.map(task => (
<div key={task.id} className="p-4 border rounded">
{task.title}
</div>
))}
</div>
)
}
That’s a full-stack feature in your Django Next.js boilerplate. No configuration needed. This starter template handles all the setup complexity.
Deploy to Production
Option 1: Docker Anywhere
# Build production images
docker-compose -f docker-compose.prod.yml build
# Deploy to your server
docker-compose -f docker-compose.prod.yml up -d
Option 2: AWS (ECS/EC2)
The template includes a deployment script with AWS placeholders:
# Configure AWS credentials
aws configure
# Deploy script included (customize for your AWS setup)
./scripts/deploy.sh production
Option 3: Vercel + Railway
- Frontend → Vercel (automatic from GitHub)
- Backend → Railway (one-click PostgreSQL + Redis)
What You Get Out of the Box
Authentication Structure: User models and auth setup (JWT coming soon)
Type Safety: TypeScript + mypy + strict mode
Code Quality: Pre-commit hooks for Python + JS
Testing: pytest + Playwright configured
API Docs: Auto-generated OpenAPI specs
Admin Panel: Django admin pre-configured
Hot Reload: Both frontend and backend
Common Customizations
Remove What You Don’t Need
# Don't need Celery?
# Delete from docker-compose.yml:
- celery
- celery-beat
- redis
# Don't need authentication?
# Remove backend/apps/users/
Add Your Preferred Tools
# Want GraphQL instead of REST?
cd backend && uv add strawberry-graphql
# Want Prisma instead of Django ORM?
cd backend && npm install prisma
Change the Database
# backend/config/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # or mongodb
# ...
}
}
The Fast Path to Shipping
- Clone the template → 30 seconds
- Run setup script → 2-3 minutes
- Start coding features → Immediately
- Deploy to production → Varies by platform
If you have suggestions, please open an issue or better yet, send a PR!
I’ve built and deployed several SaaS apps in 1-2 days using this Django Next.js starter template. You can too.
Get the open source boilerplate: github.com/code-geek/ai-project-template
Now go build something.