Cloud Stack for AI Apps — Mastery2 / 8
Next.js on Vercel — The App Layer
One framework for UI, API and server rendering; one platform that deploys on git push. The app layer should be the part you never think about.

The app layer is where most of your code lives, so the goal is to make it the part you think about least. Next.js on Vercel gets you there: UI, API, and rendering in one framework, deployed on push.
One framework, three jobs
- Server Components fetch data and render on the server — no separate API call for page data.
- Route handlers (
app/api/*) are your backend endpoints: checkout, webhooks, LLM proxies. - Streaming lets you push tokens to the browser as the model generates — essential UX for AI.
Streaming an LLM response
For anything generative, stream. A route handler returns a ReadableStream; the client renders tokens as they arrive. Users tolerate a slow complete answer far less than a fast streaming one.
Edge vs. Node
- Edge — low latency, globally distributed, but a limited runtime (no full Node APIs).
- Node — full APIs (most SDKs, file ops), slightly higher cold-start.
Default to Node for LLM and DB routes (SDK compatibility); use Edge for lightweight, latency-sensitive endpoints.
Next: the data layer that backs it — Supabase.
Series — Cloud Stack for AI Apps — Mastery
- Part 01The Opinionated AI Product StackChoosing infrastructure is where weeks vanish. Here is a default stack that lets a small team ship an AI product in days — and when to deviate.
- Part 02Next.js on Vercel — The App Layer — you are hereOne framework for UI, API and server rendering; one platform that deploys on git push. The app layer should be the part you never think about.
- Part 03Supabase — Postgres, Auth & Storage in OneReal Postgres, auth, file storage and pgvector behind one SDK. For an AI product, having your data and your vectors in the same database is a quiet superpower.
- Part 04Stripe — Payments & SubscriptionsCharging money is a solved problem — if you let Stripe solve it. Checkout, subscriptions, and the webhook that is the real source of truth.
- Part 05Resend — Transactional Email That LandsThe receipt, the download link, the password reset — if they hit spam, your product feels broken. Deliverability is a feature.
- Part 06AWS — When You Outgrow the Managed PathThe managed stack covers 90% of an AI product. AWS is the escape hatch for the other 10% — long jobs, GPU inference, large files. Use it surgically.
- Part 07Secrets, Env & Config Across EnvironmentsFive services, three environments, one leaked key away from a bad week. Config discipline is unglamorous and non-negotiable.
- Part 08Shipping in Days — The Wiring PlaybookThe whole stack assembled into a build order: from empty repo to a paid, emailing, AI-powered product in a working week.