Emergent

Deploy and Manage › Deployment

Platform Documentation

Complete guide to building and deploying on Emergent.sh

Understanding the Basics

What is Preview vs Deployment?

FeaturePreviewDeployment
What it isYour testing playgroundYour live app
How long it lastsUpto 30 minutes (if there is no interaction), then stopsAlways online
Resources (CPU/RAM)High (more powerful)Lower (optimized)
URL looks likeyourapp.preview.emergentagent.comyourapp.emergent.cloud/yourapp.emergent.host
DatabasePreview databaseProduction database
CostOnly development credits50 credits ($10) first time (starter tier)

Info

Simple Rule: Preview and deployment are completely separate. When you make changes in preview, you must redeploy to see them live.

Machine Types in Preview (add more context - what and why does the user need to know)

MachinePowerWhen to Use
RegularStandard powerNormal development
LargeExtra powerTesting heavy features

Info

On paid tiers, the switch between machine types happens automatically. On basic tiers, the agent will stop and user must wake up the agent with a larger machine (simple button press)

Before You Deploy

Success

Agent is awake (deployment won't work if agent is asleep) App works in preview (fix all errors before deploying) Not using too much compute (app will shut down if it uses too much) - have to explain what is compute Optimize your queries - instruct the agent to write optimized code Plan ahead if your database will be large - reach out in advance to ensure your app is deployed smoothly.

Phase 1: Build Phase

What Happens Here?

Your code gets compiled and prepared for production. Think of it like packing your app into a box ready to ship.

What Gets BuiltFrom Where
Frontend (what users see)Your React code
Backend (the server)Your Python/FastAPI code
JavaScript packagespackage.json file
Python packagesrequirements.txt file

Note

Time: ~5 minutes

The Big Problem: Heavy Libraries

In PreviewIn DeploymentThe Rationale
Heavy libraries work fine (high resources)Heavy libraries fail (lower resources)why this is the way it is
Example: Can use pandas, matplotlibExample: These will timeout or crash

Warning

Why This Happens: Deployment has less CPU and RAM than preview. What works in testing might not work when live. Emergent allows users more freedom to create an app and then scale as you grow

The Solution: Use APIs Instead

Don't Install ThisDo This Instead
pandas, matplotlib, plotlyUse external data analysis APIs
Large AI/ML librariesUse OpenAI API, Hugging Face API
Playwright, SeleniumUse external automation services
Heavy image toolsUse Cloudinary or imgix API
Big calculationsUse AWS Lambda or Cloud Functions

Tip

Simple Rule: If a library is large, use an API service instead of installing it - say why.

Some Examples of External Services You Can Integrate With

Service TypeSome ExamplesWhat It DoesThe Reason
File StorageAmazon S3, Google Cloud StorageStore images, videos, PDFs
DatabasesSupabase, PostgreSQLHandle lots of data
File HostingCloudinaryManage images and media

Info

What is the difference between a db and a storage service - why the investment is worth it to build serious apps.

Some Common Build Errors

ErrorWhat It MeansHow to Fix (What to tell the agent)
"Module not found"Missing from package.json or requirements.txtAdd the missing package
"Build timeout"App is too heavyRemove heavy libraries, use APIs
"Syntax error"Code has mistakesFix the code error
"Out of memory"Using too much RAMOptimize code, reduce packages

How to Fix Build Problems (with the agent)

1

Share logs with agent

Use the one-click log sharing button [add GIF] or copy logs and share in chat

2

Ask agent to optimize

Tell the agent to optimize your code

3

Agent identifies the relevant action

The agent will perform the fix and solve the error

4

Test again

Verify everything works in preview

5

Perform a one click Health Check

It is strongly recommended to ask the agent to perform a health check before attempting to deploy again. This ensures the app has a much better chance of a clean deployment.

6

Deploy Your App

Once solved, attempt to deploy your app again.

Phase 2: Database Migration

What Happens Here?

Your data moves from preview to production. Like moving your furniture to a new house.

Note

Time: 1-2 minutes

What is a Database?

TypeHow It WorksHow we handle it
RelationalData in tables (like Excel)You can connect your own database.
Non-RelationalData in flexible documentsMongoDB by default

Info

Emergent uses MongoDB by default, which is flexible and easy to work with.

How Our Databases Work

What You Need to KnowDetails
Shared hostingMultiple users share the same cluster - simplify
Preview vs deploymentThey are completely separate databases
Built-in storageCan store large amounts of text & limited files, images, PDFs in MongoDB - replace with a better explanation - _why we suggest external connections. _
Queries must be optimizedSlow queries will fail during deployment

Warning

Important: The agent cannot see your deployed database unless you share logs. Preview and deployment are separate environments.

When Databases Get Too Heavy

ProblemSolution
Storing many large imagesUse Amazon S3 or Google Cloud Storage
Lots of videos or PDFsUse file hosting service like Cloudinary
Very large datasetsUse Supabase or PostgreSQL
High traffic appGet dedicated database (contact support)

Making Queries Optimized

Query SpeedResultWhat to Do
Unoptimized queriesDeployment may fail, or timeoutAsk agent to optimize
Optimized queriesDeployment has improved performanceReady to go

Tip

How to Optimize: Tell the agent "optimize my database queries" and it will rewrite them better.

Common Database Errors (shows up in logs, share with agent to fix)

ErrorWhat It MeansHow to Fix (Ask the agent)Simple Fix
"Connection failed"Can't connect to databaseCheck MONGO_URL in .env fileFork and Replace deployment
"Query timeout"Query too slowAsk agent to optimize queries
"Schema error"Data format is wrongAsk agent to fix

Connecting Your Own Database

1

Get credentials

Get URL and password from your database provider

2

Share with agent

Provide credentials to the Emergent agent

3

Agent configures

Agent sets up the connection

4

Test connection

Verify it works in preview

5

Deploy

Deploy with your custom database

Phase 3: Exporting Secrets

What Are Secrets?

Secrets are passwords, API keys, and settings your app needs. They go in the .env file.

Note

Time: 1-2 minutes

Two Types of Secrets

TypeExamplesWho Provides
Emergent gives youMongoDB URL, Backend URL, Port, CORSAutomatic
You provideAPI keys, your database passwords, external servicesYou

The Golden Rules

Never put secrets in code

Anyone can see them (security risk)

Always use .env files

Easy to change, stays private

Be very careful editing

One wrong character breaks everything

Must redeploy after changing

Changes only work after you redeploy

What Breaks Your App

If This is WrongThis Happens
Port numberApp can't connect
URLYou get 404 errors
API keyExternal services don't work
Database URLCan't load any data

Warning

Be careful! Double-check everything before deploying.

Common Secret Errors

ErrorWhat It MeansHow to Fix
"Missing variable"You forgot to add it to .envAdd the missing variable
"Invalid API key"Key is wrong or expiredGet a new valid key
"Connection refused"URL or port is wrongFix the URL or port number

Best Practices

Make sure they work by testing them in preview first

Save a copy in case you need to restore settings

Use descriptive names so you know what each does

External services need to know your new domain

Phase 4: Deploy and Health Check

Deploy: Setting Up Infrastructure

Your app is launched on servers and made available to the world.

What Happens:

  • Servers are set up (Kubernetes)
  • Your app is installed on servers
  • Network connections are configured
  • Resources (CPU/RAM) are assigned

Note

Time: 3-5 minutes

Common Deploy Errors

ErrorWhat It MeansHow to Fix
"Provisioning failed"Server setup problemWait and try again, contact support if it keeps failing
"Container crashed"App won't startCheck logs, fix startup code
"Port conflict"Port already being usedCheck port settings
"Out of resources"App needs too much powerOptimize app, use external APIs

Health Check: Is Everything Working?

After deployment, the system checks if your app is actually working.

What Gets Checked:

  • App responds to requests
  • APIs are working
  • Frontend loads correctly
  • Database is connected
  • All services are running

Note

Time: 1-2 minutes

If Health Check Fails

ProblemWhat It MeansHow to Fix
"App crashed"Code error on startupReview logs, fix the error
"API error 500"Backend has problemsCheck backend code
"White screen"Frontend won't loadCheck frontend build
"Database failed"Can't connect to databaseVerify connection info
"CORS error"Security settings wrongFix CORS configuration

Warning

Important: If health check fails, your app won't go live. This protects you from publishing a broken app.

Total Deployment Time

All Phases CombinedTypical Time
Build + Database + Secrets + Deploy + Health Check10-15 minutes

Understanding Deployment Costs

How Much Does It Cost?

WhatCostWhen You Pay
First time you deploy50 credits ($10)Once per app
Update same app (redeploy)FREEEvery time after first
Deploy a new app50 credits ($10)Once per new app

What Do You Get for 50 Credits?

24/7 Uptime

Your app runs always online

Database Hosting

Managed MongoDB included

Build Pipeline

All deployment steps included

Custom Domains

Auto-linking for your domains

Tip

Good News: After paying once, you can update your app unlimited times for free.

What Happens When You Redeploy?

This UpdatesThis Stays the Same
Your code (frontend and backend)Your database (from first deployment)

Warning

Important: Redeploying updates your code but NOT your database. If you changed data in preview after your first deployment, that data won't appear in production. You need to manually move it.

Replacing Existing Deployments

Why Replace Instead of Deploy New?

Scenario: You forked your app, made it better, and want the new version to replace the old one WITHOUT paying another 50 credits.

Your Options

OptionWhen to UseWhat Happens to Data
Fresh startNo important data to keepOld data deleted, start fresh
Keep old dataUsers have important dataOld data stays
Merge dataWant old AND new data togetherCombines both databases

Option 1: Fresh Start (Copies Preview Data)

1

Replace deployment

Click "Replace Existing Deployment"

2

Choose fresh database

Select "Fresh Database" option

3

Deploy

New app replaces old one

Result: Old app gone, new app live, no extra charge.

Option 2: Merge Old and New Data

1

Request export

Email support@emergent.sh to export data (up to 24 hours)

2

Download data

Get your data when ready (few minutes)

3

Share with agent

Give data to agent, ask to merge

4

Check for conflicts

Tell agent to verify no data conflicts

5

Deploy merged data

Deploy with combined database

Result: All data preserved, no extra charge.

Option 3: Zero Risk Method (High Traffic Apps)

1

Export old data

Request from support (time only)

2

Deploy new app separately

Deploy as standalone (50 credits)

3

Add old data

Load exported data to new app

4

Verify everything

Check all data and features work

5

Turn off old app

Shut down old app (free)

Result: Zero downtime, zero data loss, but costs 50 credits.

Working with URLs and Domains

The Three Types of URLs

URL TypeLooks LikeWhen It's OnlinePower
Previewapp.preview.emergentagent.com30 minutes onlyHigh
Deployedapp.emergent.hostAlwaysNormal
Your domainyourdomain.comAlwaysNormal

Adding Your Own Domain

1

Buy a domain

Purchase from GoDaddy, Namecheap, etc (right away)

2

Change DNS settings

Update at your domain provider (right away)

3

Auto-link in Emergent

Use Emergent dashboard (5-10 minutes)

4

Wait for propagation

DNS spreads worldwide automatically (10 min to 2 hours)

Warning

After You Link Domain: Update all external services (APIs, payment processors, OAuth) to use your new domain instead of the old emergent.host URL.

Troubleshooting Guide

Quick Problem Solver

ProblemQuick Fix
Build failsShare logs with agent, check for missing packages
Database failsCheck MONGO_URL, ask agent to optimize queries
Deploy failsCheck logs, contact support if it keeps happening
App won't startCheck .env file for wrong values
Domain doesn't workWait 10 min to 2 hours for DNS to update
APIs stop workingUpdate URLs at external service providers
Preview shuts downUse Large machine or make app lighter
Can't deployWake up the agent first

When to Share Logs

ProblemWhat Logs Show
Build failsWhat packages are missing
Database failsWhat queries are slow
Deploy failsWhat infrastructure problem occurred
App crashesWhat code error happened

Tip

How: Click the one-click log share button, send to agent, agent tells you how to fix.

When to Email Support

Email support@emergent.sh when:

ProblemWhat to Include
Same error keeps happeningJob ID, logs, what you tried
Server/infrastructure issuesJob ID, error message
Need to export databaseJob ID, how big your database is
Want dedicated databaseHow much traffic you have
Domain problemsYour domain name, DNS settings

Pre-Deployment Checklist

Success

Works perfectly in preview (catch problems early) Database queries are fast (prevent timeouts) Using APIs instead of heavy libraries (avoid crashes) All packages listed in config files (prevent build errors) API keys work (make sure integrations function) Secrets in .env file, not code (security) Agent is awake (can't deploy if agent is asleep)

Quick Reference

Key Terms Simple Guide

TermWhat It Means
PreviewTesting area, stops after 30 min, high power
DeploymentLive app, always on, normal power
RedeployUpdate your code for free (same app)
Job IDYour app's unique number
Heavy libraryBig package that works in preview but fails when deployed
External APIService you connect to instead of installing locally
.env fileWhere you store passwords and keys
AgentAI helper that builds and fixes your app
Made with Emergent