Migrate a Next.js App from Vercel to AWS
What Actually Breaks in Production (and How to Fix It)
Overview
Deploying a Next.js app on Vercel is straightforward because most infrastructure concerns are handled automatically.
When moving the same application to Amazon Web Services, these responsibilities shift to you.
This guide walks through the most common issues developers face when migrating Next.js apps from Vercel to AWS, and how to fix them to keep your application stable and production-ready.
Estimated time: 1 hour
Problem
Developers move away from Vercel once their app starts growing.
Costs go up, you need more control, or you hit limitations in how things are set up.
Moving to Amazon Web Services gives you that flexibility but it also means you’re now responsible for everything Vercel was handling for you.
That’s where things start to break.
The same app that worked perfectly before can run into issues like:
Wrong environment variables -> API or DB calls fail
Files don’t persist -> uploads disappear after restart
Too many DB connections -> random 500 errors
Cache not shared -> users see different data
No logs/alerts -> failures are hard to debug
These aren’t code problems.
Their infrastructure assumptions that no longer hold once you leave Vercel.
How Stakpak Helps?
Moving to Amazon Web Services means dealing with a lot more moving parts.
Stakpak simplifies that.
No need to learn every AWS service -> just describe what you want, Stakpak handles the setup
Understands your infrastructure -> scans your app and figures out how everything is connected
Handles the heavy lifting -> networking, services, configs, and integrations
Finds and fixes issues as you go -> no digging through logs or AWS consoles
Keeps everything consistent -> avoids misconfigurations across environments
Instead of spending time figuring out AWS, you can focus on your app and let Stakpak handle the rest.
Architecture

Application
What the app does
A user submits feedback feature request, bug, question, or idea.
It appears on the homepage, sorted by votes.
Other users upvote posts they agree with.
Posts can include images (screenshots or mockups).
Search and filters help find posts by keyword, category, or status.
Clicking a post opens a detail page with comments.
A dashboard shows total posts, votes, statuses, and top items.
You can check the code source here
Now we can start that we understand the app and the architecture, we can start migrating it
Step-by-Step Guide
Prerequisites
Cloud provider credentials configured
Deployment
All you need to do is open Stakpak and ask it to
migrate this app from Vercel to AWSIt will start by analyzing the app

Then, as you can see, it will start asking us questions about the different deployment options

Let's choose the Open Next + Terraform

Here, it's asking if we want to choose Terraform or the AWS CDK, lets choose Terraform

Then it asks if we have a custom domain
Here, it shows the concerns that we were talking about earlier

Now lets let it do its magic

It Set up all AWS infrastructure, CDN, serverless functions, storage, caching, 41 resources in total with Terraform
Migrated file uploads, images now stored in S3 and served through CloudFront CDN instead of Vercel's ephemeral filesystem
Then it Handled CloudFront signing, created a fetch wrapper so all browser actions (voting, posting, commenting, uploading) work seamlessly through AWS
Pulled secrets automatically, grabbed Supabase credentials from the Vercel dashboard using Stakpak's browser extension
Now lets see if its working
Testing

Then it started testing the deployment:
Validated every route, tested all pages (homepage, dashboard, new post) and API endpoints (posts, stats, votes, comments, uploads) returning HTTP 200 with live data from Supabase
And tested the end-to-end user flows: uploaded an image to S3 and verified it served back through CloudFront, voted on a post, and confirmed the vote count updated
Now everything is working🥳
Now, let's ask it to set up Stakpak Autopilot
Stakpak Autopilot monitors your apps 24/7, detects unexpected changes, fixes what’s safe, and only alerts you when it actually matters.
Monitoring
Here it's asking us what do we want to monitor exactly, i chose all

That's it

Final Architecture

Extra Resources:
Related Use Cases
and more...
References
Last updated