Skip to content

Repository files navigation

🚀 Vercel to AWS Migration: Next.js Example

This repository demonstrates how to migrate a Next.js application from Vercel's proprietary edge network to standard, highly scalable AWS infrastructure using deploy-stack.

🪄 The Magic

This repository contains a standard vercel.json file with custom routing rules (301 and 302 redirects).

When you run deploy-stack, it automatically parses this file and translates those proprietary edge rules into native AWS Application Load Balancer Listener Rules.

Take a look at the bottom of terraform/network.tf to see the auto-generated infrastructure code!

# Auto-generated from vercel.json redirect
resource "aws_lb_listener_rule" "vercel_redirect_0" {
  listener_arn = aws_lb_listener.http.arn
  priority     = 100 

  action {
    type = "redirect"
    redirect {
      status_code = "HTTP_301"
      path        = "/blog/$1"
    }
  }

  condition {
    path_pattern {
      values = ["/old-blog/*"]
    }
  }
}

⚙️ Next.js Standalone Mode

To run Next.js in a Docker container on AWS Fargate without massive image bloat, you must enable standalone output.

Notice in next.config.mjs that we have added:

export default {
  output: 'standalone'
};

Note: If you forget to add this, the deploy-stack CLI will proactively warn you before generating your infrastructure!

🛠️ Try it yourself

Want to eject your own Next.js app from PaaS? Go to your project root and run:

npx deploy-stack

About

A reference implementation demonstrating how to migrate a Next.js app with vercel.json routing rules to AWS Fargate using deploy-stack.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages