Skip to content

Deploy the frontend

The frontend is a standard Next.js 15 app. It deploys cleanly to Vercel, but any platform that supports Node 20 (Netlify, Cloudflare, Fly, Render, self-hosted) works the same way.

The repo already contains a vercel.json in monitoring_dashboard/ — Vercel is the path of least resistance.

Deploy to Vercel

1. Connect the repo

  1. Sign in to https://vercel.com.
  2. Add New → Project and import the repo.
  3. Set the Root Directory to monitoring_dashboard.
  4. Framework preset: Next.js (auto-detected).
  5. Build command: bun run build. Install command: bun install.

2. Set environment variables

In Project Settings → Environment Variables add:

KeyValueEnvironments
NEXT_PUBLIC_ENVIRONMENTproductionProduction
NEXT_PUBLIC_ENVIRONMENTstagingPreview
NEXT_PUBLIC_GOOGLE_MAPS_API_KEYyour browser keyAll

See Environment variables for the full reference.

3. Wire the frontend to the backend

The frontend picks the backend URL based on NEXT_PUBLIC_ENVIRONMENT. The mapping lives in monitoring_dashboard/src/lib/ — search for the environment switch and confirm the production URL matches what Encore Cloud emitted in step 5 of Encore Cloud (backend).

If the URL needs to be tenant-specific, expose it as an env var instead:

bash
NEXT_PUBLIC_API_URL=https://staging-n2e-aq92.encr.app

…and read it from process.env.NEXT_PUBLIC_API_URL in the API client.

4. Deploy

Push to main — Vercel auto-deploys. Every PR also gets a preview URL.

Self-host

If you prefer to self-host:

bash
cd monitoring_dashboard
bun install --frozen-lockfile
bun run build
bun run start -p 3000

Reverse-proxy https://your-domainhttp://localhost:3000 with Caddy / nginx / Traefik. Make sure your TLS terminator forwards the Host and X-Forwarded-Proto headers so Next.js generates correct absolute URLs.

Docker

The repo doesn't ship a Dockerfile out of the box, but a minimal one is:

dockerfile
# monitoring_dashboard/Dockerfile
FROM oven/bun:1.3-slim AS deps
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

FROM oven/bun:1.3-slim AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN bun run build

FROM oven/bun:1.3-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
EXPOSE 3000
CMD ["bun", "run", "start"]

Build and run:

bash
docker build -t n2e-frontend monitoring_dashboard/
docker run --rm -p 3000:3000 \
  -e NEXT_PUBLIC_ENVIRONMENT=production \
  -e NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=... \
  n2e-frontend

Post-deploy checklist

  • [ ] Frontend loads at the production URL.
  • [ ] Sign-in succeeds against the Encore Cloud backend.
  • [ ] Email verification arrives in the inbox (check Resend dashboard).
  • [ ] Dashboard cards show non-zero numbers once data is seeded.
  • [ ] Google Maps tiles render (or the watermarked dev tiles, if you skipped the key).
  • [ ] Theme toggle persists across reloads.
  • [ ] No CORS errors in the browser console.

Continue to Environment variables.

N2E Fleet Management User Guide.