v0 to Production: Hardening the Server Side of a Next.js App
v0 is excellent at screens. The production work sits behind them: authorization in server code, secrets, a data layer with tenants, caching that respects users, and tests on every PR.
By the Ryz Labs team · Updated November 2026
Getting a v0 app to production is mostly server-side work. The Next.js and shadcn/ui interface v0 generated is usually worth keeping; what needs engineering is everything a user never sees: authorization inside server actions and route handlers, environment variables, the database layer, tenant isolation, caching, tests and how Vercel deployments get promoted. The deciding question for v0 projects is simple to ask and slow to answer: does every server entry point check who is calling and what they are allowed to touch?
What v0 hands you, and the line where production begins
Every new chat starts from the same base. In Vercel's words, "New v0 chats start with a Next.js app that uses shadcn/ui and Tailwind CSS," with shadcn/ui as the default component system. That's a mainstream stack, which is good news: any engineer who knows Next.js can read the output on day one.
Shipping goes through Vercel. The deployments page says simply "v0 deploys projects to Vercel," with a preview deployment per branch and a Publish action that goes to production. Source control is built around review rather than direct pushes: v0 commits to a working branch per chat and opens pull requests against your base branch, explaining that it "pushes generated changes here instead of pushing directly to the base branch." You can also import an existing GitHub repository into v0.
Data arrives through one-click integrations from the Vercel Marketplace: Neon and Supabase for Postgres, Upstash, and Vercel Blob for files. Configuration lives in environment variables, which v0's security page says are "stored in Vercel's built-in secure vault," with the rule that "only variables prefixed with NEXT_PUBLIC_ are exposed to the browser" and a warning when v0 sees that prefix used. You can set project-level environment variables that v0 has access to while it builds. For code review there's a DeepSec security check covering authorization, injection and SSRF, and the docs are explicit that "v0 only runs a review when you ask for one."
So the starting point is a clean UI, a sensible deploy target and a PR-based flow. What production adds is the part generated UI can't settle on its own: who is allowed to call each endpoint, how one customer's data is kept from another's, what happens when a webhook arrives twice, and whether a merged PR has been tested by anything other than a glance at the preview URL.
Where v0 apps break first
These are ordered by blast radius. Several are classic Next.js mistakes rather than anything v0 does uniquely, but AI-built apps tend to accumulate them quickly because the UI makes the app look finished.
1. Server actions and route handlers with no authorization
- Symptom: a delete or update button only appears for admins, but the server action behind it runs for anyone who sends the request. Route handlers under app/api take an id from the URL and return the record without asking whose it is. This is Broken Object Level Authorization, API1 on OWASP's 2023 list.
- Test: list every file containing "use server" and every route handler. Sign in as a normal user, copy a request from the browser's network panel, change the record id to one owned by a different account, and replay it.
- Repair: one authorization helper that every action and handler calls first, which loads the session, resolves the caller's role and organization, and throws otherwise. Then put ownership into the query itself (where id = ? and org_id = ?) so a missed check fails closed. Don't rely on middleware or layout checks alone; they protect pages, not the functions those pages call.
2. A secret that picked up the NEXT_PUBLIC_ prefix
- Symptom: a payment, email or LLM key works in a client component because someone renamed it with NEXT_PUBLIC_. The value is now in the JavaScript every visitor downloads. Older copies may sit in git history from before the variable moved to Vercel.
- Test: list every NEXT_PUBLIC_ variable and justify each one as safe to publish. Search the production build output for key prefixes you know. Enable GitHub secret scanning on whichever repo v0 commits into.
- Repair: rotate the exposed key, drop the prefix, and move the call into a route handler or server action that reads the variable on the server. Keep separate values for preview and production so a preview build never holds a production credential.
3. No tenant boundary in the data model
- Symptom: tables have a user_id but no organization or workspace id, or they have one and half the queries ignore it. When the first customer invites teammates, someone sees another company's projects.
- Test: create two organizations with overlapping data, then walk every list, search, export and dashboard as each. Grep the data layer for queries on tenant-owned tables that don't filter by org.
- Repair: add the tenant column everywhere it belongs, backfill it, and route all reads and writes through a small data access module that requires a tenant argument. If you chose the Supabase integration, add Postgres row-level security as a second line: Supabase warns that a table without RLS in an exposed schema is "readable and writable by any role with a grant on it." On Neon, the same scoping lives in your data access module and tests.
4. A data layer that grew one component at a time
- Symptom: SQL or ORM calls scattered across server components, no migration history, tables created by hand in a dashboard, and list pages that run one query per row. Serverless functions open fresh connections under load until the database refuses more.
- Test: enable query logging in staging, load the three busiest pages and count statements. EXPLAIN ANALYZE the slowest; look for sequential scans on foreign-key and tenant columns. Try rebuilding the schema from the repo alone.
- Repair: pick one ORM or query builder, put the schema under migrations, add indexes for every join and filter column, batch the N+1 loops, and use a pooled connection string for serverless code. If the app uses Supabase, its Performance Advisor and the pooler's transaction mode (no prepared statements) both matter here.
5. Billing webhooks that take the request at its word
- Symptom: a route handler receives payment events, parses the JSON and upgrades the account. The signature isn't checked, a retried event grants the upgrade twice or reverses a later downgrade, and the paywall exists only as a hidden button.
- Test: send the endpoint a hand-written event from curl. Replay a real event twice. Cancel a test subscription and see whether access ends.
- Repair: verify signatures against the raw body, store processed event ids and skip repeats, write entitlements to the database from the webhook only, and check them on the server in every gated action. Model failed payments, grace periods and downgrades before launch.
6. Caching that forgets who asked
- Symptom: a page or data fetch that includes per-user data gets cached and served to the next visitor, or a dashboard shows numbers from before the last write because nothing invalidates it.
- Test: sign in as two users in separate browsers, load the same routes, and compare. Make a change and time how long the old value survives.
- Repair: decide caching per route on purpose: personalized routes render dynamically, shared data is cached with keys that include tenant where needed, and every write path invalidates what it changed. Document the choice next to the route.
7. Unvalidated input, outbound fetches and LLM calls
- Symptom: actions accept whatever the form sends; an "import from URL" feature fetches any address, including internal ones; a chat feature passes user text and retrieved documents straight into a model with tools attached and no spending limit.
- Test: ask v0 for a DeepSec review, since authorization, injection and SSRF are in its scope, then confirm each finding by hand. Fuzz action inputs with wrong types and oversized payloads.
- Repair: schema-validate every action and handler input, allow-list outbound hosts, and give LLM features per-user rate limits, token budgets and a review of prompt injection paths before any tool can write data.
8. Merging on a good-looking preview
- Symptom: v0's PR flow is sound, but the only check on each PR is someone clicking through the preview deployment. There are no unit, integration or end-to-end tests, preview builds share production environment variables, and "Publish" is pressed from whichever state looked right.
- Test: open the last ten merged PRs and look for any required status check. Inspect which environment each variable is scoped to.
- Repair: branch protection on the base branch with required CI, tests on the money paths, environment-scoped variables with a separate preview database, and one documented path to production.
Pre-launch review checklist
- Inventory of every server action and route handler, each mapped to the role and tenant it requires.
- Shared authorization helper called first in every action and handler; ownership enforced in queries.
- Replay test passes: no record reachable by changing an id in a request.
- Every NEXT_PUBLIC_ variable reviewed and safe to publish; no secret in the build output or git history.
- Preview and production use different credentials and different databases.
- Tenant column on every tenant-owned table, backfilled, indexed and required by the data access module.
- RLS enabled with ownership policies if the database is Supabase.
- Schema under migrations; staging rebuilt from the repo.
- No N+1 loops on the busiest pages; pooled connections for serverless code.
- Payment webhooks verify signatures, are idempotent, and are the sole place entitlements get written.
- Per-user routes are not cached across users; writes invalidate what they change.
- All action inputs schema-validated; outbound fetches allow-listed.
- LLM features rate-limited and budgeted per user.
- DeepSec review requested and every finding triaged by an engineer.
- Required CI checks and end-to-end tests on v0 PRs before merge.
- Error tracking, logs with request ids, and a rollback procedure for production.
Hardening, phase by phase
Phase 0: Freeze and take a baseline snapshot
Pick the commit that represents production, tag it, and stop merging v0 PRs into the base branch for the moment. Export the environment variable list from Vercel (names and scopes, not values), dump the database schema, and record which Marketplace integrations are connected. Exit criteria: a tagged baseline, a schema dump, and a written inventory of routes, actions, integrations and variables.
Phase 1: Security at every entry point
Write the threat model around entry points rather than pages, since that's where v0 apps leak. Add the authorization helper, wire it into every action and handler, and put tenant filters into queries. Rotate anything exposed through NEXT_PUBLIC_ or history, verify the payment webhook, and validate inputs. Request a DeepSec review once the obvious fixes are in so its findings are the subtle ones. Exit criteria: the replay test fails for every id you try, no exposed credentials remain, and an engineer has reviewed each server entry point.
Phase 2: Data layer and performance
Consolidate data access into one module, adopt migrations, add tenant columns and indexes, and fix N+1 patterns found in query logs. Settle caching rules route by route and test them with two users. Load test the busiest routes against a staging database with realistic volume. Exit criteria: agreed latency targets met at that volume, schema reproducible from the repo, caching decisions written down.
Phase 3: Test gates and CI/CD for v0 PRs
Write characterization tests on signup, billing and the main workflow before refactoring further, then add end-to-end tests that run against each preview deployment. Turn on branch protection so v0's PRs, like everyone else's, merge only with green checks. Split environment variables by scope and give previews their own database. Exit criteria: no merge without passing CI, and production promoted through one documented path.
Phase 4: Running it in production
Instrument server and client with error tracking, structured logs with request, user and tenant ids, uptime checks on key routes, and alerts with an owner. Document rollback to a previous deployment, key rotation, database restore and webhook replay. Exit criteria: rollback and restore rehearsed in staging; on-call knows where to look.
Phase 5 (optional): Move out only what outgrew Next.js
If background work, long jobs or heavy integrations have outgrown request-scoped functions, move them to a worker or a separate API service and let the Next.js app call it. Keep the UI. Exit criteria: extracted services have their own tests, deploys and owners.
| Phase | Goal | Key technique | Exit criteria |
|---|
| Baseline | A known baseline | Tagged commit, schema dump, route and variable inventory | Inventory written; baseline restorable |
| Entry-point security | Every entry point authorizes | Shared authz helper, tenant filters in queries, key rotation, DeepSec on request | Replay test fails everywhere; no exposed keys |
| Data layer | One data layer that scales | Migrations, indexes, N+1 fixes, pooled connections, per-route caching | Latency targets met; schema reproducible |
| Test gates | PRs gated by tests | Characterization and end-to-end tests, branch protection, scoped env vars | Every merge has passing checks |
| Running it | Visible, reversible production | Error tracking, tenant-aware logs, runbook | Previous deployment restorable on demand |
| Optional extraction | Move only what outgrew functions | Workers or a separate API | Each service has tests, a deploy and an owner |
What an AI pod on your team does in the first two weeks
Week one
- Join the GitHub repo, the Vercel project and the database provider; map which branches v0 is writing to.
- Build the entry-point inventory and the threat model with your tech lead.
- Run the id-replay test on every action and handler; audit NEXT_PUBLIC_ variables and git history.
- Pin current behavior with characterization tests around signup, billing and the main workflow.
- Add a CI pipeline with required checks, plus staging on its own database.
- Connect error tracking on server and client.
- Merge the first authorization and secret fixes through reviewed PRs.
Week two
- Add tenant columns and scoping, and the RLS policies if you're on Supabase.
- Rebuild the payment webhook with signature checks, duplicate-event protection, and handling for downgrades and declined cards.
- Put the busiest routes under load, then fix the worst queries and caching rules.
- Draft the incident runbook and agree an on-call rota alongside your engineers.
- Present the remaining-scope plan: keep, harden, extract.
Our AI pod teams use coding assistants for the tedious work, such as scaffolding tests, drafting the authorization wrapper for dozens of actions, codemods across components and sorting through logs. A human reviews every change, and nothing merges without the tests passing.
Keep, harden or rebuild a v0 app?
| Situation | Recommendation |
|---|
| Good UI, real users, gaps in authorization, env vars and tests | Keep and harden in place |
| Business logic spread across dozens of actions, plus jobs and integrations | Keep the Next.js front end; move logic into a separate API |
| No tenant concept and enterprise customers on the way | Rework the data model first; keep the screens |
| The product has moved far from what v0 generated | Rebuild, using the current app as the spec |
| Pre product-market fit, an internal tool, or a demo a weekend of fixes would cover | Skip the team; fix the authorization gaps yourself |
A team earns its cost once customers, payments or a procurement security review are in the picture. Before that, keep iterating in v0 and protect the few entry points that touch real data.
Typical team shape
For a v0 codebase: a tech lead with production Next.js experience, between one and three senior engineers who work across the stack in TypeScript and server-side React, part-time DevOps and security help for Vercel configuration and the authorization review, with QA automation added once billing and role logic grow tangled. Many teams begin with a pod of 3 to 5 senior engineers (a tech lead plus engineers), and a full pod is about seven. A narrow v0 cleanup may need only a lead and a single engineer at first.
Ryz engineers on your team start from $7,000 per month (our published range is $7,000–$15,000 per engineer per month, mostly mid-level to senior), quoted per team. Budget is the product of headcount, months and each person's rate. Once you say go, engineers can typically start in under two weeks. Ryz engineers work on your team, reporting to your leads. Tell us about the repo and scope your team.
Related
FAQ
Will a v0 app hold up under production traffic?
The stack can: it's Next.js on Vercel with a managed database behind it. What decides it is the server code. An app whose actions skip authorization, whose queries run per row, or whose per-user pages are cached for everyone will fail under real users long before raw traffic is the problem.
Is a rewrite required?
Rarely. The shadcn/ui components and page structure are usually fine to keep. Most effort goes into server actions, route handlers, the data layer and tests. A rewrite is worth considering when there's no tenant model and the product has drifted far from what was generated.
How long will hardening take?
The drivers are the number of server entry points, how scattered the data access is, whether billing and multiple tenants are involved, how much caching is in play, and the bar set by your customers' security reviews. The entry-point inventory from the first days gives a much better basis for an estimate than the size of the UI.
What will it cost us?
Multiply headcount by months by each person's monthly rate; seniority sets the rate. We scope a quote per team after reading the repo and the inventory of routes and actions, and we don't quote fixed project prices up front.
Can product people keep building in v0 afterwards?
No. v0 already works through a branch per chat and pull requests, which fits a normal engineering workflow. With branch protection and required checks, product people can keep generating UI in v0 while engineers own the server code, and every v0 PR gets the same tests as any other.
Questions we didn't answer? Email info@ryzlabs.com.