Scripts2026年7月16日·1 分钟阅读

OpenNext — Run Next.js on AWS Without Vendor Lock-In

An open-source adapter that packages Next.js applications for deployment on AWS Lambda, CloudFront, and S3, providing a self-hosted alternative to Vercel.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
OpenNext
直接安装命令
npx -y tokrepo@latest install 1d9812f0-80af-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

OpenNext is an open-source adapter that takes a standard Next.js build output and packages it for deployment on AWS infrastructure. It bridges the gap between Next.js features (SSR, ISR, middleware, image optimization) and AWS services (Lambda, CloudFront, S3), giving teams full control over their hosting without sacrificing Next.js capabilities.

What OpenNext Does

  • Converts Next.js build output into AWS-compatible Lambda functions
  • Handles server-side rendering, static generation, and incremental static regeneration on AWS
  • Supports Next.js middleware via CloudFront Functions or Lambda@Edge
  • Provides image optimization through a dedicated Lambda function
  • Manages cache revalidation with SQS or direct invocation patterns

Architecture Overview

OpenNext transforms the Next.js standalone build into a deployment package with three main components: a server function (Lambda) for SSR and API routes, a static asset bucket (S3) for pre-rendered pages and assets, and a CDN distribution (CloudFront) for routing and caching. Middleware runs at the edge via CloudFront Functions. ISR revalidation uses a separate queue-based mechanism to avoid cold-start latency on cache updates.

Self-Hosting & Configuration

  • Add open-next as a dependency to your existing Next.js project
  • Run npx open-next build to generate the AWS deployment package
  • Deploy using SST, CDK, Terraform, or any AWS IaC tool
  • Configure custom domains and SSL certificates through CloudFront
  • Tune Lambda memory, timeout, and concurrency settings per function

Key Features

  • Supports App Router and Pages Router with full SSR/ISR/SSG
  • Next.js middleware runs at the edge with low latency
  • Image optimization without Vercel's proprietary service
  • Works with SST, CDK, Terraform, Pulumi, and raw CloudFormation
  • Active community maintaining compatibility with latest Next.js releases

Comparison with Similar Tools

  • Vercel — seamless Next.js hosting but proprietary and can be expensive at scale
  • Netlify — supports Next.js but with feature gaps in ISR and middleware
  • AWS Amplify Hosting — managed AWS option but slower to adopt new Next.js features
  • Coolify — self-hosted PaaS but not AWS-optimized for Next.js
  • Docker deployment — works but loses edge caching and serverless scaling benefits

FAQ

Q: Does OpenNext support all Next.js features? A: It supports SSR, SSG, ISR, middleware, API routes, image optimization, and App Router. Check the compatibility matrix in the docs for edge cases.

Q: Do I need SST to use OpenNext? A: No. SST is the recommended deployment tool, but OpenNext's build output works with any AWS IaC tool including CDK, Terraform, and Pulumi.

Q: How much does it cost to run Next.js on AWS with OpenNext? A: Costs depend on traffic. For many applications, AWS Lambda and CloudFront are significantly cheaper than equivalent Vercel plans, especially at scale.

Q: Can I migrate from Vercel to OpenNext? A: Yes. OpenNext is designed as a drop-in build step for existing Next.js projects. No code changes are required in most cases.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产