How to Migrate Off Emergent (Step-by-Step)
A practical guide to migrate off Emergent. Save your code to GitHub, move MongoDB, replace the Emergent LLM key, and deploy FastAPI and React on your own server.
Emergent’s agents build real, standard apps: React on the frontend, Python FastAPI on the backend, MongoDB for data. That’s great news if you want to leave, because nothing has to be rewritten from scratch. It still takes a plan, because the parts that make the app run live on Emergent.
Short version: GitHub gets you the code. A complete Emergent migration also moves the MongoDB data, replaces the universal LLM key with your own, re-issues secrets, and redeploys on hosting you own.
Step 1: Save the code to GitHub
Emergent’s GitHub integration is available from the Standard plan up. Connect it and save the project to a repository in your own account or organization. Clone it and make sure both halves start locally:
cd backend && pip install -r requirements.txt && uvicorn server:app --reload
cd frontend && yarn install && yarn start
If your app has a mobile version, it’s an Expo (React Native) project and comes along the same way.
Step 2: Review what the agents wrote
Nobody on your team wrote this code, so read it before you move it. Build an inventory:
| Item | Where to look | Why it matters |
|---|---|---|
| Environment variables | backend/.env, frontend/.env |
Each needs a new value on your stack |
| Collections | Models and queries in the backend | Your data migration list |
| LLM calls | Imports from emergentintegrations |
Need your own provider keys |
| Integrations | Stripe, email, storage clients | Keys must be re-issued |
| Settings | CORS, auth, secrets in code | Harden before production |
Step 3: Replace the Emergent LLM key
Emergent’s universal LLM key gives your app access to GPT, Claude and Gemini with usage billed through Emergent credits. On your own stack you call the providers directly:
# before
from emergentintegrations.llm.chat import LlmChat, UserMessage
chat = LlmChat(api_key=os.environ["EMERGENT_LLM_KEY"], ...)
# after
from anthropic import Anthropic
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
Set usage limits and billing alerts in each provider’s console while you’re there.
Step 4: Provision your infrastructure
A simple, reliable target:
- App server: an EC2 instance or VPS running FastAPI with Uvicorn behind Nginx, serving the React build as static files.
- Database: MongoDB Atlas, or MongoDB on your own server with backups.
- Secrets: your host’s environment settings or a secret manager.
- SSL: Certbot, or your platform’s managed certificates.
Step 5: Move the data
Export every collection and restore it into your database. With mongodump and mongorestore access, it’s two commands. Without direct access, export through an authenticated admin endpoint you add to the backend. Then check document counts per collection and recreate indexes. See the MongoDB migration guide for details.
Step 6: Deploy and test
Set up CI so a push to main deploys both halves. Point REACT_APP_BACKEND_URL (or your equivalent) at the new API, and test sign-up, sign-in, payments, uploads and every AI feature on a staging domain.
Step 7: Cut over
- Freeze writes on the Emergent app.
- Run the final data sync and compare counts.
- Point your domain at the new stack.
- Keep the Emergent deployment for a couple of weeks as a fallback, then stop it to save the monthly hosting credits.
Want it done for you?
X & Company runs this playbook on every Emergent migration, from code review to cutover, for a fixed-scope quote.