Overview
shrtnr is built with Next.js 16 and requires a PostgreSQL database (Neon) and Redis cache (Upstash) for optimal performance. This guide walks you through the complete deployment process.Prerequisites
Before deploying, ensure you have:- Node.js 20+ installed
- A Neon account for PostgreSQL
- An Upstash account for Redis
- A deployment platform (Vercel, Railway, or similar)
Tech Stack
Next.js 16.1.6
Modern React framework with App Router
Neon PostgreSQL
Serverless PostgreSQL with auto-scaling
Upstash Redis
Serverless Redis for caching and rate limiting
NextAuth v5
Authentication with credentials provider
Dependencies
The application uses the following core dependencies:package.json
Deployment Steps
Set Up Neon PostgreSQL
- Create a new project at neon.tech
- Copy your connection string from the dashboard
- The connection string format:
postgresql://user:password@host/database?sslmode=require
Neon provides a pooled connection string - use this for serverless environments
Set Up Upstash Redis
- Create a new Redis database at upstash.com
- Copy the REST URL and REST Token from the dashboard
- Upstash Redis uses HTTP-based requests, perfect for serverless
Configure Environment Variables
Create a See Environment Variables for complete reference.
.env.local file with your credentials:.env.local
Initialize Database
Run the database initialization script:This creates all required tables and indexes. See Database Setup for schema details.
Deploy to Production
- Vercel
- Railway
- Docker
Vercel automatically detects Next.js and configures build settings
Production Checklist
Security
Security
-
AUTH_SECRETis a strong random string (32+ characters) - Environment variables are not committed to git
- HTTPS is enabled on your domain
- Database connections use SSL
- Rate limiting is configured in Redis
Performance
Performance
- Redis caching is active for link lookups
- Database indexes are created (handled by migration)
- Next.js is running in production mode
- CDN is configured for static assets
Monitoring
Monitoring
- Error tracking is configured (e.g., Sentry)
- Uptime monitoring is active
- Database connection pooling is enabled
- Log aggregation is set up
Troubleshooting
Database connection fails
Database connection fails
- Verify
POSTGRES_URLis correct - Check if Neon project is active
- Ensure SSL mode is included:
?sslmode=require - Test connection with:
npm run test:db
Redis connection errors
Redis connection errors
- Verify
UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKEN - Check Upstash dashboard for database status
- Ensure REST API is enabled (not just regular Redis protocol)
NextAuth authentication issues
NextAuth authentication issues
- Verify
AUTH_SECRETis set - Set
NEXTAUTH_URLto your production domain - Check that
trustHost: trueis enabled in production - Ensure users table exists in database
Next Steps
Environment Variables
Complete reference for all configuration options
Database Schema
Understand the database structure and migrations