Description
OpenNext takes the Next.js build output and converts it into packages that can be deployed across a variety of environments. Natively OpenNext has support for AWS Lambda, and classic Node.js Server.
Features
OpenNext aims to support all Next.js 15 features. Some features are work in progress. If you are running into any problems make sure to check the docs first before you open a new issue or visit our Discord to let us know!
- App & Pages Router
- API routes
- Dynamic routes
- Static site generation (SSG)
- Server-side rendering (SSR)
- Incremental static regeneration (ISR)
- Middleware
- Server actions
- Image optimization
- NextAuth.js
- Running at edge
- Almost no coldstart (*)
Who is using OpenNext?
Gymshark UK, Udacity, TUDN, NHS England
Configuration
Configuration file
For personalisation you need to create a file open-next.config.ts at the same place as your next.config.js, and export a default object that satisfies the OpenNextConfig interface. It is possible to not have an open-next.config.ts file, the default configuration will then be applied automatically.
Debug mode
OpenNext can be executed in debug mode by setting the environment variable OPEN_NEXT_DEBUG=true before your build.
This will output A LOT of additional logs to the console. This also disable minifying in esbuild, and add source maps to the output. This can result in code that might be up to 2-3X larger than the production build. Do not enable this in production.
You can read more about the configuration in the docs
Preleases
Besides the standard npm releases we also automatically publish prerelease packages on branch pushes (using pkg.pr.new):
https://pkg.pr.new/opennextjs/adapters-api/@opennextjs/aws@main:
Updated with every push to the main branch, this prerelease contains the most up to date yet (reasonably) stable version of the package.
https://pkg.pr.new/opennextjs/adapters-api/@opennextjs/aws@experimental
Updated with every push to the experimental branch, this prerelease contains the latest experimental version of the package (containing features that we want to test/experiment on before committing to).
The URLs include the opennextjs/adapters-api owner/repo prefix: the compact form
(https://pkg.pr.new/@opennextjs/aws@main) resolves through the npm repository field, which still
points at the previous repositories, so it would serve packages from the wrong repo.
Which you can simply install directly with your package manager of choice, for example:
npm i https://pkg.pr.new/opennextjs/adapters-api/@opennextjs/aws@main
Contribute
To run OpenNext locally:
Clone this repository.
Build open-next:
cd packages/open-next
pnpm build
Run open-next in watch mode:
pnpm dev
Now, you can make changes in open-next and build your Next.js app to test the changes.
cd path/to/my/nextjs/app
path/to/opennextjs-aws/packages/open-next/dist/index.js build
There is also a way to run OpenNext locally. You can read a guide about it here. Its mostly used for development/debugging purposes.
Testing
Install Node.js 24 and pnpm 10, then install the workspace dependencies:
pnpm install --frozen-lockfile
Unit tests
Run all unit tests, including the AWS and Cloudflare adapter tests, with:
pnpm test
To run only the Cloudflare adapter unit tests, use:
pnpm --filter @opennextjs/cloudflare test
End-to-end tests
Before running the e2e tests for the first time, install Chromium:
pnpm exec playwright install chromium --with-deps
AWS adapter
Build the AWS adapter and example applications, then start the local servers:
pnpm --filter @opennextjs/aws... run build
pnpm openbuild:local
pnpm openbuild:local:start
Keep the servers running and, in a different shell, run:
pnpm e2e:test
Cloudflare adapter
Build the Cloudflare adapter and example Workers, then run the Playwright tests in the Cloudflare Workers environment:
pnpm --filter @opennextjs/cloudflare run build
pnpm turbo build:worker:cf
CI=1 pnpm turbo e2e:cf
The final command starts and stops the required local Wrangler preview servers. Setting CI=1 matches the CI workflow, where the Workers have already been built by the preceding command.
Coldstart
OpenNext provide you with a warmer function that can be used to reduce cold start.
On Lambda, there are multiple scenarios where a lambda will trigger a cold start even if you have some warmed instance. For example if you have more requests than warm instances you'll get a cold start. Also NextJs lazy load the routes, so even if you hit a warm instance, this specific route might not have been loaded yet.
Acknowledgements
We are grateful for the projects that inspired OpenNext and the amazing tools and libraries developed by the community:
Special shoutout to @khuezy and @conico974 for their outstanding contributions to the project.
Maintained by SST. Join our community: Discord | YouTube | Twitter