🚀 6. Deployment
Guide to deploying TaskNexus to production.
☁️ Recommended Hosts
Since this is a Next.js application with a PostgreSQL database, we recommend:
- Vercel: Best for Next.js frontend/backend hosting.
- Railway / Render: Good for hosting both the App and the Database.
- Supabase / Neon: Excellent managed PostgreSQL databases.
📦 Build Process
The package.json build script is:
prisma generate runs before next build, because Next.js needs the generated Prisma client to compile the pages.
Steps for Vercel
- Connect your GitHub Repository.
- Environment Variables: Add all variables from your
.env.DATABASE_URLGEMINI_API_KEYNODE_ENV=productionSESSION_SECRET
- Build Command: Default (
next build) is usually fine, but ensure the "Install Command" runsnpm install.- Override Build Command (if needed):
npx prisma generate && next build
- Override Build Command (if needed):
- Deploy.
⚠️ Important Considerations
-
Database Connection Pooling:
- Serverless functions (like Vercel) can exhaust database connections.
- Use a Connection Pooler (like Supabase Transaction Pooler or Neon Pooling).
- Update your
DATABASE_URLto the pooled connection string.
-
Cold Starts:
- First request might be slow as the lambda wakes up and connects to the DB.
- This is normal for serverless.
-
Timeouts:
- AI generation can take 10-30 seconds.
- Vercel Free Tier has a 10s timeout limit on Server Functions.
- Solution: Upgrade to Pro (60s limit) OR optimize AI prompts to be shorter.