# Preview vs Live isolation

> Iterate fearlessly in Preview without touching production. Preview and Live never share databases, user accounts, storage buckets, or Stripe keys.

- Canonical: https://exaspark.ai/docs/preview-vs-live/

## Why two isolated environments matter

Every ExaSpark project runs two completely independent environments from day one: **Preview** (your live-updating build workspace) and **Live** (the production app serving real customers on your `.exaspark.app` URL or custom domain).

In many DIY setups, developers accidentally point a staging copy at their production database, or run a test payment against a live Stripe key. One careless edit can wipe customer bookings, email fake receipts to real buyers, or corrupt financial totals.

ExaSpark eliminates that entire failure class by design. **Preview** and **Live** never share database rows, registered user accounts, uploaded file buckets, or Stripe payment keys. You can break layouts, delete rows, test declines, and experiment with new roles in **Preview** while real customers continue using **Live** undisturbed.

*Figure: How ExaSpark isolates Preview and Live data planes — promoting verified code and additive schema changes on Publish while leaving Live customer data untouched.*

## Complete side-by-side environment matrix

Use this matrix whenever you want to know exactly where an action takes effect.

| Layer | Preview environment | Live environment |
| --- | --- | --- |
| **Audience & URL** | Private workspace preview for you and your team while iterating | Public `.exaspark.app` address or your verified custom domain |
| **When code updates** | Automatically right after every Agent turn | Strictly when you click **Publish** |
| **Database rows** | Isolated test database you can seed, edit, or wipe anytime | Protected production database holding real customer records |
| **User accounts & sessions** | Test users and test admin sessions; separate login state | Real customer sign-ups and active production sessions |
| **File storage buckets** | Dedicated Preview bucket for sample photos and test PDFs | Separate Live bucket holding real catalog media and customer receipts |
| **Stripe payments** | **Test mode** accepting Stripe test cards (zero real money moves) | **Live mode** charging real cards and paying out to your bank |
| **Transactional email** | Safe testing without emailing real Live customers | Live customer verification, booking confirmations, and receipts |
| **Secrets & provider keys** | Preview-scoped configuration and test keys | Production-scoped credentials and live webhook secrets |
| **Analytics & ads** | Excluded from Live traffic metrics and ad conversion tracking | Captures real visitor traffic, conversions, and health signals |

## What actually happens when you click Publish

Understanding the exact boundary of **Publish** prevents the two biggest surprises new builders hit on launch day: expecting test rows to show up on Live, or worrying that publishing code will erase customer orders.

### What Publish promotes to Live

- **Application code and UI.** Every updated page, mobile layout, API route, validation rule, email template, and role check moves forward atomically.
- **Schema definitions.** New tables, new columns, new constraints, and new indexes are applied cleanly to your Live database so new screens have the structure they expect.
- **Static assets bundled in code.** Brand logos, icons, and illustrations compiled inside your project ship together with the release.

### What Publish NEVER copies to Live

- **Preview database rows.** Seeded test products, fake bookings, and sample members stay strictly in Preview — they never pollute your Live catalog or sales charts.
- **Preview user accounts.** A test admin account you registered in Preview does not exist in Live. On your first launch, sign up on your Live URL and promote your Live account in **Cloud → Live**.
- **Preview file uploads.** Images or PDFs uploaded through forms while testing stay inside your Preview storage bucket.
- **Preview Stripe test orders.** Test charges never appear in Live Stripe revenue or trigger payouts.

### Handling schema changes during Publish

Additive schema changes — such as adding a new `notes` table or an optional `coupon_code` column — apply cleanly to Live without disturbing existing customer rows.

If a change alters or removes an existing populated column (renaming a field or changing a text column to integer), tell ExaSpark explicitly that Live already holds customer data so it migrates existing values safely instead of dropping them. See [Database & data modeling](https://exaspark.ai/docs/accounts-and-data/) for the full safe-migration guide.

## Safely testing risky changes in Preview

Because **Preview** is completely walled off from **Live**, use it as a full dress rehearsal before every major release.

1. **Confirm you are inspecting Preview in Cloud** — Check the **Preview / Live** switcher at the top of the **Cloud** tab before seeding, editing, or clearing tables.
2. **Test destructive user flows fearlessly** — Delete records, cancel active subscriptions, upload invalid file types, and try accessing another user's private route to verify your error handling holds up.
3. **Run Stripe Test mode end-to-end** — Walk through a successful checkout, a declined card, and a 3D Secure prompt in Preview, then verify the resulting status rows in **Cloud (Preview)**.
4. **Click Publish and run a calm Live check** — Once Preview behaves cleanly, click **Publish**, open your Live URL in an incognito window, and verify the updated screens load without errors.

> **Example prompt (App):** Add an optional `referral_source` column (defaulting to null) to our `users` table and show an optional "How did you hear about us?" dropdown on sign-up. Keep all existing Live user records untouched, treat missing values as "Not specified" in the Admin dashboard, and seed 5 Preview users with different referral sources so we can test filtering before publishing.

## Rolling back a Live release cleanly

Even careful releases occasionally introduce an unexpected UI regression or edge-case bug. ExaSpark separates **code rollbacks** from **live customer data** so you can recover in minutes without losing business transactions.

- **Reverting application code.** Restore a previous working checkpoint from your workspace history (or roll back a commit via the Official GitHub App) and click **Publish**. Your Live URL returns to the last verified version immediately.
- **Why live customer data is preserved.** Rolling back code never rewinds your Live database. If a real customer placed an order five minutes before you reverted a layout bug, their paid order remains safely recorded in **Cloud (Live)**.
- **Designing rollback-friendly updates.** Keeping schema changes additive (adding optional columns rather than dropping live fields in the same release) guarantees older code can still read and write your Live database cleanly if you ever need to revert quickly.

## Common Preview vs Live misconceptions

If something works in Preview and behaves differently on your Live URL, check this table first — nine times out of ten, isolation is working exactly as intended.

| What you see | Why it happens | What to do |
| --- | --- | --- |
| **"My Live store has zero products even though I added 12 in Preview"** | Preview database rows and uploaded product photos never copy to Live on Publish | Sign into your Live admin dashboard (or **Cloud → Live**) to add real production catalog items |
| **"My admin login works in Preview, but says invalid credentials on Live"** | Preview and Live keep completely separate user account tables | Register your real account on the Live URL, then assign the `admin` role in **Cloud → Live** |
| **"Stripe test card `4242...` failed on my Live checkout"** | Live payments are switched to **Live mode**, which rejects Stripe test card numbers | Run test card checks in **Preview** (Test mode), or run one small real-card smoke test on Live and refund it |
| **"I deleted a row in Cloud and want to make sure Live is safe"** | Check which tab was active: **Preview** edits never affect **Live** | Always verify the **Preview / Live** environment badge at the top of **Cloud** before clicking Delete |

> **Note:** **Golden rule before editing Cloud rows:** Pause for one second and check whether **Cloud** is showing **Preview** or **Live**. Use **Preview** freely for experiments, resets, and QA; treat **Live** as your production ledger.

## Next steps

- [Publish & rollback](https://exaspark.ai/docs/publish/) — Ship verified Preview builds to `.exaspark.app` or a custom domain.
- [Database & data modeling](https://exaspark.ai/docs/accounts-and-data/) — Evolve live schemas safely with additive columns and backfills.
- [Testing & subscriptions](https://exaspark.ai/docs/testing-stripe-and-webhooks/) — Run full Stripe Test mode QA before switching Live on.

## From the blog

- [What is web hosting?](https://exaspark.ai/blog/what-is-web-hosting/) — How staging previews, production servers, and live deploys fit together.
- [Frontend vs backend explained](https://exaspark.ai/blog/frontend-vs-backend/) — Why separating code deploys from live databases keeps apps safe.
- [App security basics](https://exaspark.ai/blog/app-security-checklist/) — Practical launch checks for isolation, roles, and live credentials.
