Skip to main content

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:

Deployment Steps

1

Import Project

  1. Log in to Vercel
  2. Click Add NewProject
  3. Import your Nectr GitHub repository
  4. Vercel will automatically detect Next.js
2

Configure Root Directory

The Next.js app is in the nectr-web/ subdirectory:
  1. In the project settings, set Root Directory to nectr-web
  2. Vercel will detect vercel.json with this configuration:
vercel.json
{
  "rootDirectory": "nectr-web",
  "framework": "nextjs"
}
If you already have vercel.json in your repo root, Vercel will automatically use these settings.
3

Set Environment Variables

Add the following environment variable in Vercel project settings:
NEXT_PUBLIC_API_URL=https://your-backend.up.railway.app
Important: Replace your-backend.up.railway.app with your actual Railway backend URL.
Do NOT include a trailing slash in NEXT_PUBLIC_API_URL. The frontend appends paths like /api/v1/repos.
4

Deploy

  1. Click Deploy
  2. Vercel will build and deploy automatically
  3. Monitor the build logs for any errors
  4. Once deployed, copy your Vercel URL (e.g., https://nectr.vercel.app)
5

Update Backend Environment

Return to Railway and update the FRONTEND_URL environment variable:
FRONTEND_URL=https://nectr.vercel.app
This ensures CORS is configured correctly for authentication cookies.
6

Update GitHub OAuth App

If you haven’t already, update your GitHub OAuth App’s Homepage URL:
https://nectr.vercel.app
The Authorization callback URL should remain pointing to Railway:
https://your-backend.up.railway.app/auth/github/callback

Verify Deployment

1

Test Landing Page

Visit your Vercel URL and verify the landing page loads correctly.
2

Test Authentication

  1. Click Sign in with GitHub
  2. Complete OAuth flow
  3. Verify you’re redirected to /dashboard
  4. Check that the dashboard loads data from the backend
3

Check API Connectivity

Open browser DevTools → Network tab and verify:
  • API requests go to your Railway backend URL
  • Requests include credentials: 'include' for cookies
  • CORS headers are present in responses

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 in nectr-web/src/lib/api.ts:
nectr-web/src/lib/api.ts
import axios from 'axios';

const api = axios.create({
  baseURL: process.env.NEXT_PUBLIC_API_URL,
  withCredentials: true,  // Send httpOnly cookies
});

export default api;

Environment Variable Usage

The NEXT_PUBLIC_API_URL variable is used throughout the app:
Example: useRepos hook
const { data } = await api.get('/api/v1/repos');
// Resolves to: https://your-backend.up.railway.app/api/v1/repos

Continuous Deployment

Vercel automatically deploys on every push:
  1. Push changes to your main branch
  2. Vercel detects the commit
  3. Builds the Next.js app with npm run build
  4. Deploys with zero-downtime
  5. 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:
1

Add Domain

  1. Go to Vercel project SettingsDomains
  2. Add your domain (e.g., nectr.yourdomain.com)
2

Configure DNS

Add a CNAME record in your DNS provider:
Type:  CNAME
Name:  nectr
Value: cname.vercel-dns.com
3

Wait for Verification

Vercel will automatically verify and issue SSL certificates.
4

Update Environment Variables

Update FRONTEND_URL in Railway to use your custom domain:
FRONTEND_URL=https://nectr.yourdomain.com

Troubleshooting

Symptom: Console shows CORS policy errorsSolution:
  1. Verify FRONTEND_URL is set correctly in Railway
  2. Check that NEXT_PUBLIC_API_URL points to Railway backend
  3. Ensure Railway backend includes CORS middleware:
app.add_middleware(
    CORSMiddleware,
    allow_origins=[settings.FRONTEND_URL],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
Symptom: User logged out on page refreshSolution:
  1. Verify cookies are being set by checking DevTools → Application → Cookies
  2. Ensure cookies have these attributes:
    • httpOnly: true
    • secure: true (requires HTTPS)
    • sameSite: "none" (for cross-origin)
  3. Verify withCredentials: true in axios config
Symptom: Changed NEXT_PUBLIC_API_URL but app still uses old valueSolution:
  1. Environment variables are baked into the build at build time
  2. Trigger a new deployment in Vercel after changing variables
  3. Hard refresh the browser (Cmd+Shift+R or Ctrl+Shift+R)
Symptom: Vercel build logs show errorsSolution:
  1. Check that all dependencies are in nectr-web/package.json
  2. Verify Node.js version compatibility
  3. Test build locally:
cd nectr-web
npm install
npm run build
  1. Check for TypeScript errors

Performance Optimization

Enable Edge Runtime

For faster response times, consider enabling Edge Runtime for API routes:
app/api/route.ts
export const runtime = 'edge';

Image Optimization

Next.js automatically optimizes images. Use the <Image> component:
import Image from 'next/image';

<Image
  src="/logo.png"
  alt="Nectr Logo"
  width={200}
  height={50}
  priority
/>

Analytics

Vercel provides built-in analytics:
  1. Go to project Analytics tab
  2. 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

  1. Go to Vercel project → Deployments
  2. Click on a deployment
  3. View Build Logs or Function Logs

Real-Time Logs

Install Vercel CLI for real-time logs:
npm i -g vercel
vercel login
vercel logs https://nectr.vercel.app --follow

Next Steps

Connect Repositories

Connect your first GitHub repository

Configure Integrations

Set up Linear, Sentry, or Slack integrations

Build docs developers (and LLMs) love