Production-ready Next.js 16 template with tRPC, Prisma, shadcn/ui, Vercel Analytics, Sentry, and rate-limited API routes
A complete, opinionated fullstack Next.js starter that includes everything you need to build and deploy production-ready applications.
npx degit willem4130/nextjs-fullstack-template my-app
cd my-app
npm install- Click "Use this template" button on GitHub
- Create your repository
- Clone and install:
git clone https://github.com/willem4130/your-new-repo.git
cd your-new-repo
npm installnpx create-nextjs-fullstack my-app
cd my-app- β‘ Next.js 16 - App Router, React 19, Turbopack
- π· TypeScript - Strict mode, full type safety
- π¨ Tailwind CSS 3 - Utility-first styling
- π§© shadcn/ui - Beautiful, accessible components
- π tRPC v11 - End-to-end typesafe APIs
- ποΈ Prisma ORM - Type-safe database client
- π PostgreSQL - Production database (configured)
- β Zod - Runtime validation
- π Admin Dashboard - Professional UI with sidebar navigation
- π Protected API Routes - Rate limiting, authentication, validation
- π‘οΈ Rate Limiting - Upstash Redis integration
- π Analytics - Vercel Analytics + Speed Insights (privacy-friendly)
- π Error Tracking - Sentry integration with session replay
- π Environment Validation - Type-safe env vars with @t3-oss/env-nextjs
- π§ͺ Testing - Vitest (unit) + Playwright (e2e)
- π Code Quality - ESLint, Prettier, Husky, lint-staged
- π Documentation - Complete setup guides included
- Dashboard - Stats cards, recent activity, metrics
- Users - User management with data tables
- Settings - Application configuration
- Health Check -
/api/health - Documentation -
/api(auto-generated) - Posts CRUD -
/api/postswith full CRUD operations - Rate Limited - All endpoints protected
- Validated - Zod schemas for all inputs
10 shadcn/ui components pre-installed:
- Card, Table, Button, Dropdown Menu, Badge
- Avatar, Separator, Input, Label, Select
npm installCopy .env.example to .env and configure:
cp .env.example .envRequired:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"Optional (but recommended):
# Upstash Redis (rate limiting) - https://upstash.com
UPSTASH_REDIS_REST_URL="your-url"
UPSTASH_REDIS_REST_TOKEN="your-token"
# API Authentication
API_SECRET_KEY="generate-with-openssl-rand-base64-32"
# Sentry (error tracking) - https://sentry.io
NEXT_PUBLIC_SENTRY_DSN="your-dsn"
SENTRY_ORG="your-org"
SENTRY_PROJECT="your-project"
SENTRY_AUTH_TOKEN="your-token"# Push schema to database
npm run db:push
# Or create migration
npm run db:migratenpm run devVisit http://localhost:3000
- Homepage:
/- Landing page - Admin Dashboard:
/admin/dashboard- Admin interface - API Docs:
/api- API documentation - Sentry Test:
/sentry-test- Error tracking test page
Comprehensive guides included in the repository:
- ANALYTICS.md - Vercel Analytics setup
- API_DOCUMENTATION.md - Complete API reference
- SENTRY_SETUP.md - Error tracking guide
npm run dev # Start dev server with Turbopack
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run format # Format code with Prettier
npm run typecheck # Run TypeScript type checkingnpm run test # Run Vitest unit tests
npm run test:ui # Open Vitest UI
npm run test:e2e # Run Playwright e2e tests
npm run test:e2e:ui # Open Playwright UInpm run db:generate # Generate Prisma client
npm run db:push # Push schema changes
npm run db:migrate # Create migration
npm run db:studio # Open Prisma Studionextjs-fullstack-template/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (auth)/ # Protected routes
β β βββ (public)/ # Public routes
β β βββ admin/ # Admin dashboard
β β βββ api/ # API routes
β β βββ error.tsx # Error boundary
β β βββ layout.tsx # Root layout
β βββ components/ # React components
β β βββ ui/ # shadcn/ui components
β βββ lib/ # Utilities
β β βββ api-middleware.ts # API helpers
β β βββ rate-limit.ts # Rate limiting
β βββ server/ # Backend code
β β βββ api/ # tRPC routers
β β βββ db/ # Prisma client
β βββ trpc/ # tRPC client config
β βββ env.js # Environment validation
βββ prisma/
β βββ schema.prisma # Database schema
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ e2e/ # E2E tests
βββ public/ # Static files
- Update
package.jsonname field - Update database name in
.env - Update metadata in
src/app/layout.tsx
The template is ready for authentication. Recommended options:
- NextAuth.js - OAuth, credentials, magic links
- Clerk - Drop-in authentication
- Better Auth - Modern auth library
Follow the pattern in src/app/api/posts/route.ts:
import { protectedRoute, apiResponse, validateRequest } from '@/lib/api-middleware'
export async function GET(request: NextRequest) {
return protectedRoute(request, async (req) => {
// Your logic here
return apiResponse({ data: 'your-data' })
})
}npx shadcn@latest add dialog
npx shadcn@latest add form
npx shadcn@latest add toastComplete Deployment Guide: See DEPLOYMENT.md for detailed instructions.
-
Push to GitHub
git push origin main
-
Import to Vercel
- Go to vercel.com
- Click "Add New Project"
- Import your GitHub repository
-
Set Environment Variables (required)
DATABASE_URL="postgresql://..." DIRECT_URL="postgresql://..." NODE_ENV="production"
-
Deploy!
- Vercel auto-detects Next.js configuration
- Build command:
prisma generate && next build(pre-configured) - Every push to
mainauto-deploys to production - Pull requests create preview deployments
Vercel automatically configures:
- β Analytics (privacy-friendly)
- β Speed Insights
- β Edge Functions for API routes
- β Serverless Functions
- β Automatic HTTPS
- β Global CDN
- β Preview deployments for PRs
- Database configured (PostgreSQL recommended)
- Environment variables set in Vercel
- Upstash Redis for rate limiting (optional but recommended)
- Sentry for error tracking (optional)
- Custom domain configured (optional)
Full deployment guide with troubleshooting: DEPLOYMENT.md
This is a template repository. Feel free to:
- Fork it
- Customize for your needs
- Share improvements via PR
MIT License - use freely for personal and commercial projects.
Built with:
Ready to build? Start with npx degit willem4130/nextjs-fullstack-template my-app π