npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aws-amplifygen3/adapter-nextjs

v1.0.2

Published

Amplify hosting adapter and build command for Next.js (native deployment adapters API, with an OpenNext compatibility path for older Next.js versions)

Readme

@aws-amplifygen3/adapter-nextjs

Next.js adapter and build command for the Amplify hosting platform. It emits a deployable .amplify bundle (deployment manifest, compute server, and static assets) through one of two paths, selected by the app's Next.js version:

  • Next.js 16.2+ — native adapter. Next.js calls the adapter through its deployment adapters API at the end of next build.
  • Next.js 14.2 – 16.1 — OpenNext compatibility path. The build command runs next build in standalone mode, then transforms the output with OpenNext.

Usage

As a build command (any supported version)

From your Next.js app directory, with the package installed as a dependency:

npx @aws-amplifygen3/adapter-nextjs build

The command detects the Next.js version and takes the matching path. On 16.2+ it runs next build with the native adapter wired in through NEXT_ADAPTER_PATH.

As a Next.js adapter (Next.js 16.2+)

// next.config.js
module.exports = {
  adapterPath: require.resolve("@aws-amplifygen3/adapter-nextjs"),
};

Then run next build as usual.

Either way, output lands in .amplify/:

  • deployment-manifest.json — regex route rules, compute config, static assets, image settings
  • static/ — client-side assets (_next/static/, favicon.ico, etc.)
  • compute/default/ — server bundle (see Output Structure below)

The @aws-amplifygen3/adapter-nextjs/build entry point exposes the same pipeline programmatically.

Package layout

  • src/ — the native adapter (src/adapter.ts, the package's main entry)
  • src/opennext/ — the build command (cli.ts, build.ts) and the OpenNext compatibility path
  • dist/bundle/adapter.mjs — bundled native adapter, with its runtime templates in dist/bundle/runtime/
  • dist/bundle/opennext/cli.mjs — bundled build command (the adapter-nextjs bin), with its runtime templates in dist/bundle/opennext/runtime/
  • dist/bundle/node_modules/ — dependencies vendored for both bundles

Package contents

The published package is compiled JavaScript with type declarations. The .ts files under dist/bundle/runtime/ and dist/bundle/opennext/runtime/ are build-time templates, not sources to compile on install: the adapter bundles them into the compute output of your app with esbuild during next build. dist/bundle/node_modules/ vendors the adapter's own runtime dependencies, except esbuild: its native binary is platform-specific, so it is a declared dependency that your npm install provides for your platform.

Prerequisites

  • Node.js >= 22
  • npm (installed via workspace root)

Setup

From the workspace root:

npm install

Build

Compile TypeScript to dist/ and produce the bundles in dist/bundle/:

npm run build

Test

Unit + Property Tests (fast)

npm test

Runs the unit and property tests for both paths: manifest generation, compute bundling, cache handlers, middleware, route generation, size validation, and error messages.

Integration Tests (requires network)

npm run test:integration

Includes everything from npm test plus:

  • OpenNext-path integration tests that dynamically scaffold a Next.js app (both 15.x and 16.x), build it, and verify the .amplify output structure, including runs from an isolated copy of dist/bundle/
  • Manifest snapshot tests

These tests run npm install and npx next build in a temp directory, so they require network access and take several minutes.

E2E Tests (hosting emulator)

npm run test:e2e

Builds fixture apps (test/fixtures/ for the native adapter, test/opennext/fixtures/ for the OpenNext path), starts the hosting emulator, and verifies HTTP responses for API routes, SSR pages, and server actions.

Update Snapshots

OpenNext-path snapshots are local-only (gitignored). When running integration tests for the first time or after manifest changes:

TEST_INTEGRATION=true npx vitest run --update

Run a Single Test File

npx vitest run test/manifest-generator.test.ts
npx vitest run test/opennext/createAmplifyBundle.test.ts
npx vitest run test/opennext/properties/size-validation.prop.test.ts

Deploying

The .amplify directory produced by the build is the deployment artifact. Deploy it with the Amplify hosting tooling for your project.

Running the hosting emulator

The deployment-manifest package ships a local emulator that serves a built .amplify directory:

node node_modules/@aws-amplifygen3/deployment-manifest/dist/cjs/emulator/hosting-emulator.js --output-dir .amplify

Then verify routes:

curl http://localhost:8085/              # SSR home page
curl http://localhost:8085/api/hello     # API route (JSON)
curl http://localhost:8085/blog/test     # Dynamic route
curl http://localhost:8085/about         # Static page

Output Structure (OpenNext path)

.amplify/
├── deployment-manifest.json
├── static/
│   ├── _next/static/...
│   ├── favicon.ico
│   └── robots.txt
└── compute/
    └── default/
        ├── index.js               (runtime proxy entrypoint)
        ├── server.js              (Next.js standalone server)
        ├── middleware.mjs         (Next.js middleware bundle)
        ├── open-next.config.mjs   (OpenNext config)
        ├── cache.cjs              (cache handler)
        ├── composable-cache.cjs   (composable cache handler)
        ├── patchedAsyncStorage.cjs
        ├── assets/                (server-side assets)
        ├── node_modules/          (runtime dependencies)
        └── wasm/                  (WebAssembly modules)

For a monorepo (npm-workspaces) app, OpenNext nests the standalone server and the server runtime entrypoint under the app's package path — index.js and server.js live at compute/default/<packagePath>/ (e.g. compute/default/apps/web/) instead of the compute root, while node_modules/ stays at the compute root. The deployment manifest's compute.default.entrypoint points at the nested index.js accordingly.

Deployment Manifest

The adapter generates deployment-manifest.json conforming to the Amplify deployment specification. Key sections:

  • routes — ordered regex route rules: static assets (immutable cache), image optimization, per-page compute routes with trailing-slash redirects, error pages (404/500), catch-all fallback
  • compute — NodeJs-24.x runtime with an index.js entrypoint. On the OpenNext path, a monorepo (npm-workspaces) app nests the standalone server under the app package path, so the entrypoint is declared as <packagePath>/index.js (e.g. apps/web/index.js) to match the actual bundle layout
  • staticAssets — path to static directory
  • imageSettings — sizes, domains, remotePatterns, formats, minimumCacheTTL, dangerouslyAllowSVG (read from Next.js build output)

Route patterns use regex syntax (e.g. ^/api/hello$, ^/blog/([^/]+)$) with support for dynamic segments ([id]), catch-all segments ([...slug]), and optional catch-all segments ([[...path]]). Every pattern is checked against the platform's fancy-regex engine through @aws-amplifygen3/deployment-manifest/regex.

Build-Time Validations

  • Compute bundle size ≤ 250 MB
  • Individual static asset ≤ 100 MB
  • Deployment manifest schema validation via validateHostingManifest
  • Cache-control directive validation
  • All errors follow [Next.js] {step} failed: {details}. {remediation} format

Troubleshooting

| Issue | Fix | | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | runtime proxy not found | Run npm run build in this package | | standalone server.js not found | Add output: 'standalone' to next.config.js | | Compute bundle size validation failed | Remove unused dependencies or check esbuild externals | | Static asset size validation failed | Compress or remove the oversized file | | require is not defined | Ensure the proxy uses createRequire (already fixed in current version) | | Snapshot test fails after manifest change | Run npx vitest run --update and review the diff | | 500 on routes importing pg / @aws-sdk/dsql-signer (Next 16.1.x) | Build with next build --webpack — see Turbopack and native server dependencies |

Turbopack and Native Server Dependencies

On Next.js 16.1.x, next build with Turbopack (the default) externalizes server dependencies such as pg and @aws-sdk/dsql-signer under content-hashed names (e.g. pg-587764f78a6c7a9c). Those hashed specifiers do not resolve inside the deployed Lambda, so any route importing them returns a 500 at runtime.

Building with the webpack bundler instead resolves these correctly:

next build --webpack

serverExternalPackages and declaring the packages as direct dependencies do not work around this — use the webpack build until the upstream Turbopack behavior changes.

Supported Next.js Versions

  • Next.js 16.2+ — native adapter (build command or adapterPath)
  • Next.js 16.0 – 16.1 — OpenNext compatibility path (experimental — some features may not work as expected)
  • Next.js 14.2 – 15.x — OpenNext compatibility path (14.2 is the minimum)