This guide covers setting up the database (Neon PostgreSQL) and OAuth authentication (Google, GitHub) for NextCalc Pro.
- Database Setup (Neon PostgreSQL)
- OAuth Setup (Google & GitHub)
- Environment Variables Reference
- Troubleshooting
- Serverless: Scales to zero when idle
- Free Tier: Generous free plan for development
- Fast: Global edge locations
- Branching: Database branches for dev/staging
Alternatives: Supabase, Railway, AWS RDS, or any PostgreSQL instance.
- Go to neon.tech and sign up
- Click New Project with name
nextcalc-pro - Choose PostgreSQL 15+ and your closest region
- Copy the pooled connection string (recommended for serverless)
cp apps/web/.env.example apps/web/.env.localUpdate apps/web/.env.local:
DATABASE_URL="postgresql://user:password@host.neon.tech:5432/database?sslmode=require"
DIRECT_DATABASE_URL="postgresql://user:password@host.neon.tech:5432/database?sslmode=require"pnpm install
pnpm --filter @nextcalc/database db:generate
pnpm --filter @nextcalc/database db:push # Development
# OR
pnpm --filter @nextcalc/database db:migrate # Productionpnpm --filter @nextcalc/database db:studio # Opens at http://localhost:5555pnpm --filter @nextcalc/database db:seed- Database setup complete (above)
- App running locally at
http://localhost:3005
- Go to Google Cloud Console
- Create a new project named
NextCalc Pro - Enable Google+ API (APIs & Services > Library)
- Configure OAuth consent screen (External):
- App name:
NextCalc Pro - Scopes:
userinfo.email,userinfo.profile - Add your email as test user
- App name:
- Create OAuth client ID (Credentials > Create > Web application):
- Authorized origins:
http://localhost:3005 - Redirect URI:
http://localhost:3005/api/auth/callback/google
- Authorized origins:
- Copy Client ID and Client Secret
- Go to GitHub Developer Settings > OAuth Apps
- Click New OAuth App:
- Homepage URL:
http://localhost:3005 - Callback URL:
http://localhost:3005/api/auth/callback/github
- Homepage URL:
- Click Register application
- Generate and copy Client Secret (shown only once)
# apps/web/.env.local
NEXTAUTH_URL="http://localhost:3005"
NEXTAUTH_SECRET="generate-with-openssl-rand-base64-32"
GOOGLE_CLIENT_ID="xxxxx.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="GOCSPX-xxxxx"
GITHUB_ID="xxxxx"
GITHUB_SECRET="xxxxx"Generate NEXTAUTH_SECRET:
openssl rand -base64 32
# Windows PowerShell:
[Convert]::ToBase64String((1..32|%{Get-Random -Max 256}))pnpm devand openhttp://localhost:3005- Click Sign In > Sign in with Google/GitHub
- Authorize and verify redirect back to app
- Verify user record created in database via Prisma Studio
Create separate OAuth apps for production:
- Google: redirect URI
https://nextcalc.io/api/auth/callback/google - GitHub: callback URL
https://nextcalc.io/api/auth/callback/github - Update
NEXTAUTH_URLto production domain
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
NEXTAUTH_URL |
Application URL |
NEXTAUTH_SECRET |
NextAuth encryption secret |
GOOGLE_CLIENT_ID |
Google OAuth client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth secret |
GITHUB_ID |
GitHub OAuth client ID |
GITHUB_SECRET |
GitHub OAuth secret |
| Variable | Description |
|---|---|
DIRECT_DATABASE_URL |
Direct (non-pooled) connection |
UPSTASH_REDIS_REST_URL |
Redis for rate limiting/caching |
UPSTASH_REDIS_REST_TOKEN |
Redis auth token |
NEXT_PUBLIC_ENABLE_PLOT_ENGINE |
Enable plot engine (default: true) |
| Error | Solution |
|---|---|
| "Can't reach database server" | Check connection string, ensure ?sslmode=require, wake Neon project |
| "P3014: Could not create shadow database" | Use prisma db push instead of migrate dev for Neon |
| Connection pooling issues | Use pooled connection string: ?sslmode=require&pgbouncer=true |
| Missing Prisma client | Run pnpm --filter @nextcalc/database db:generate |
| Error | Solution |
|---|---|
redirect_uri_mismatch |
Verify redirect URI exactly matches OAuth app config |
invalid_client |
Double-check credentials, restart dev server |
| "Access blocked: invalid request" | Complete OAuth consent screen setup, add test users |
| Session not persisting | Check DATABASE_URL, verify Session model in schema, run prisma db push |
| Package | Version |
|---|---|
| Next.js | 16.2.0-canary.69 |
| React | 19.3.0-canary |
| TypeScript | 6.0.0-dev.20260301 |
| Prisma | 7.5.0-dev.33 |
| Apollo Server | 5.4.0 |
| Biome | 2.4.4 |
| Turborepo | 2.8.13-canary.8 |
| Tailwind CSS | 4.2.1 |
| Hono (workers) | 4.12.3 |
| Wrangler | 4.69.0 |
| Vitest | 4.1.0-beta.5 |
- Continue to DEPLOYMENT.md for production deployment
- Start development:
pnpm dev