Overview
Vercel is the recommended platform for hosting the Nectr Next.js 15 frontend. This guide covers deploying the React 19 dashboard with proper API connectivity and authentication.The frontend on Vercel communicates with the backend on Railway. Deploy the backend first before proceeding with this guide.
Prerequisites
Before deploying to Vercel, ensure you have:- A Vercel account
- Backend deployed to Railway (see Railway Deployment)
- Your Railway backend URL (e.g.,
https://nectr-production.up.railway.app)
Deployment Steps
Import Project
- Log in to Vercel
- Click Add New → Project
- Import your Nectr GitHub repository
- Vercel will automatically detect Next.js
Configure Root Directory
The Next.js app is in the
nectr-web/ subdirectory:- In the project settings, set Root Directory to
nectr-web - Vercel will detect
vercel.jsonwith this configuration:
vercel.json
If you already have
vercel.json in your repo root, Vercel will automatically use these settings.Set Environment Variables
Add the following environment variable in Vercel project settings:Important: Replace
your-backend.up.railway.app with your actual Railway backend URL.Deploy
- Click Deploy
- Vercel will build and deploy automatically
- Monitor the build logs for any errors
- Once deployed, copy your Vercel URL (e.g.,
https://nectr.vercel.app)
Update Backend Environment
Return to Railway and update the This ensures CORS is configured correctly for authentication cookies.
FRONTEND_URL environment variable:Verify Deployment
Test Authentication
- Click Sign in with GitHub
- Complete OAuth flow
- Verify you’re redirected to
/dashboard - Check that the dashboard loads data from the backend
Frontend Architecture
The Next.js frontend uses:- Next.js 15 with App Router
- React 19 with Server Components
- TailwindCSS 4 for styling
- Axios for API requests with credentials
API Client Configuration
The frontend’s API client is configured innectr-web/src/lib/api.ts:
nectr-web/src/lib/api.ts
Environment Variable Usage
TheNEXT_PUBLIC_API_URL variable is used throughout the app:
Example: useRepos hook
Continuous Deployment
Vercel automatically deploys on every push:- Push changes to your
mainbranch - Vercel detects the commit
- Builds the Next.js app with
npm run build - Deploys with zero-downtime
- Previous deployment remains active until new one is ready
Preview Deployments
Vercel creates preview deployments for every pull request:- Unique URL per PR
- Isolated from production
- Automatic cleanup when PR is closed
Preview deployments use the same
NEXT_PUBLIC_API_URL as production. Consider creating a staging backend for testing.Custom Domain
Add a custom domain to your Vercel project:Troubleshooting
API requests failing with CORS errors
API requests failing with CORS errors
Symptom: Console shows CORS policy errorsSolution:
- Verify
FRONTEND_URLis set correctly in Railway - Check that
NEXT_PUBLIC_API_URLpoints to Railway backend - Ensure Railway backend includes CORS middleware:
Authentication not persisting
Authentication not persisting
Symptom: User logged out on page refreshSolution:
- Verify cookies are being set by checking DevTools → Application → Cookies
- Ensure cookies have these attributes:
httpOnly: truesecure: true(requires HTTPS)sameSite: "none"(for cross-origin)
- Verify
withCredentials: truein axios config
Environment variable not updating
Environment variable not updating
Symptom: Changed
NEXT_PUBLIC_API_URL but app still uses old valueSolution:- Environment variables are baked into the build at build time
- Trigger a new deployment in Vercel after changing variables
- Hard refresh the browser (Cmd+Shift+R or Ctrl+Shift+R)
Build failing in Vercel
Build failing in Vercel
Symptom: Vercel build logs show errorsSolution:
- Check that all dependencies are in
nectr-web/package.json - Verify Node.js version compatibility
- Test build locally:
- Check for TypeScript errors
Performance Optimization
Enable Edge Runtime
For faster response times, consider enabling Edge Runtime for API routes:app/api/route.ts
Image Optimization
Next.js automatically optimizes images. Use the<Image> component:
Analytics
Vercel provides built-in analytics:- Go to project Analytics tab
- View page load times, Core Web Vitals, and visitor metrics
Cost Considerations
Vercel pricing tiers:- Hobby: Free for personal projects
- Pro: $20/month per user (recommended for production)
- Enterprise: Custom pricing
The Hobby plan is sufficient for testing, but production apps should use Pro for better performance and support.
Monitoring & Logs
View Logs
- Go to Vercel project → Deployments
- Click on a deployment
- View Build Logs or Function Logs
Real-Time Logs
Install Vercel CLI for real-time logs:Next Steps
Connect Repositories
Connect your first GitHub repository
Configure Integrations
Set up Linear, Sentry, or Slack integrations