Moving a Next.js App From Vercel to AWS: Options and Steps
To move a Next.js app from Vercel to AWS, pick a hosting model (containers on ECS behind a load balancer, or a serverless adapter), rebuild the features Vercel handled for you, such as caching, image optimization and previews, then cut over DNS with a rollback path.
Before starting, be sure the reason is real. This guide covers the decision first, then the steps.
Vendors Covered in this Article
Disclosure: We may earn a commission if you buy through some links on this page. It doesn't change what we recommend.
Should you move at all?
Good reasons: you need private networking to databases or internal services, compliance requires resources in your own AWS account, your usage makes the bill unattractive, or you want one platform for everything. Weak reasons: general dislike of a vendor, or a belief that AWS is automatically cheaper. You'll be trading a managed platform for your own operations work.
Write down what you'll take on: build pipelines, scaling, cache invalidation, certificates, logs and previews. If nobody on the team wants to own those, the migration cost may outweigh any savings. Estimate engineer time honestly, and compare with your current bill before committing.
Which hosting model should you choose?
Two broad approaches exist:
- Container on ECS (Fargate or EC2): build Next.js in standalone output mode, package it in a Docker image, run it behind a load balancer, and put a CDN in front for static assets. Familiar, predictable, and easy to reason about. You handle scaling rules and image caching yourself. Cost tradeoffs are in ECS Fargate vs EC2 cost.
- Serverless on Lambda with a CDN: community adapters translate Next.js output into functions, storage and CloudFront configuration. It scales to zero and is close to how Vercel works, but you depend on the adapter keeping up with Next.js releases, and debugging spans several services.
- Static export: if your app has no server features, exporting to static files on S3 with CloudFront is the simplest option, but you lose server rendering and route handlers.
For most small teams that need predictability, containers are the lower-risk choice. Choose serverless when scale-to-zero matters and you're comfortable owning the adapter.
How to rebuild what Vercel did for you
List each platform feature your app relies on and decide its replacement:
- Builds and deploys: a CI pipeline that builds the image, pushes it, and updates the service. See CI/CD pipeline template for Next.js.
- Caching and ISR: incremental static regeneration needs a shared cache location when you run several instances, so plan a cache store instead of relying on local disk.
- Image optimization: decide whether your containers handle it, or use a separate image service or CDN feature.
- Middleware and edge functions: check which runtime they need, since they may not behave identically off the platform.
- Environment variables and secrets: move them to a secrets store injected at deploy.
- Preview deployments: build a per-pull-request environment or accept a shared staging site.
- Logs, analytics and alerts: connect logging and monitoring, since the built-in dashboards go away.
Run the app on AWS behind a temporary hostname and go through every route, including authentication callbacks that have hard-coded domains.
How do you cut over safely?
Lower your DNS time-to-live in advance. Move a small share of traffic first if your DNS provider supports weighted routing, then increase. Watch error rate, latency, cache hit ratio and cold starts, and compare against baseline numbers from before the move. Update third-party settings that reference your domain, such as OAuth redirect URLs and webhook endpoints.
Keep the Vercel project deployed and unchanged for a rollback window. DORA's 2024 report describes deployment frequency from on demand down to one every one to six months across its clusters1, so confirm your new pipeline didn't slow releases. Also plan the account layout early; multi-account AWS setup and the Heroku to ECS checklist cover related steps.
What tends to go wrong?
Expect these:
- Stale pages after deploys because the CDN and application caches aren't invalidated together.
- Images that load slowly because optimization now runs on undersized containers.
- Authentication breaking on callback URLs still pointing at the old host.
- Surprise bills from data transfer and NAT gateways.
- No one owning on-call for the new stack. Decide before cutover.
For cloud-choice context, compare AWS vs GCP vs Azure for startups before deepening your commitment to one provider.
What Good Looks Like
Your app runs on AWS with builds, caching, images, previews and monitoring replaced, and DNS can switch back to the old host within minutes.
Building The Capability (5-Stage Skill Ladder)
How to Get Started
Disclosure: We may earn a commission if you buy through some links on this page. It doesn't change what we recommend.
Frequently Asked Questions
Is hosting Next.js on AWS cheaper than Vercel?
Not automatically. AWS can cost less at higher, steady usage, but you take on operations work. Compare your current bill with a realistic AWS estimate that includes engineering time, data transfer and load balancers.
Can I run a Next.js app on ECS?
Yes. Build in standalone mode, package it in a container, run it as an ECS service behind a load balancer, and put a CDN in front for static assets. Plan a shared cache for ISR across instances.
What do you lose when you leave Vercel?
Managed conveniences: zero-config builds, automatic preview deployments, built-in image optimization and integrated analytics. You can rebuild each on AWS, but you'll own the setup and maintenance.
How do I roll back if the migration fails?
Keep the Vercel deployment intact, use a low DNS time-to-live, and shift traffic gradually. If metrics degrade, point DNS back. Don't delete the old project until the rollback window closes.
Sources
Where we quote a benchmark, we show its source. Other figures in this guide are estimates or general guidance, so check them against your own numbers.
- Deployment frequency by DORA performance cluster (max days between deploys). DORA Accelerate State of DevOps 2024 (Google Cloud), cluster table via Octopus Deploy analysis, 2024.
Related Guides
ECS on Fargate or EC2: How to Compare the Real Cost
Compare the cost of ECS on Fargate and on EC2 using utilization, bin-packing, operations time and discounts, with a worked example and a decision rule.
A Next.js CI/CD Pipeline: Stages, Checks and Deploy Gates
The stages a Next.js pipeline needs, in order: install, lint, type check, test, build, preview, promote. With caching, secrets and rollback advice.
A Multi-Account AWS Layout for SOC 2: Dev, Staging, Prod
Design a multi-account AWS setup that separates dev, staging and production, centralizes logs and guardrails, and gives SOC 2 auditors clean evidence.
Moving From Heroku to AWS ECS: A Checklist by Stage
A staged checklist for moving an app from Heroku to AWS ECS: mapping dynos and add-ons, containers, database cutover, DNS and a rollback plan.
AWS vs Google Cloud vs Microsoft Azure: Cloud Platforms for Startups Compared
Compare AWS, Google Cloud, and Microsoft Azure for startups: startup credits, Kubernetes engines, AI APIs, reliability budgets, and developer velocity.
AWS vs Google Cloud for B2B SaaS: Cloud Platform Comparison
Compare AWS and Google Cloud for B2B SaaS: hosting COGS, GKE vs EKS, RDS Aurora vs Cloud SQL, SOC 2 compliance, and multi-tenant security architecture.