diff --git a/aws-node-nextjs-web-app/README.md b/aws-node-nextjs-web-app/README.md index 6b274569b..ffea9c46b 100644 --- a/aws-node-nextjs-web-app/README.md +++ b/aws-node-nextjs-web-app/README.md @@ -12,13 +12,95 @@ authorAvatar: 'https://avatars1.githubusercontent.com/u/13742415?s=200&v=4' # Next.js app on AWS Lambda Web Functions -This example deploys a [Next.js](https://nextjs.org/) app to [AWS Lambda Web Functions](https://docs.aws.amazon.com/lambda/latest/dg/web-functions.html). A web function runs an HTTP server as it is, so the Next.js production server runs unchanged: no adapter, no handler. +[![Verified](https://raw.githubusercontent.com/serverless/examples/verified/badges/aws-node-nextjs-web-app.svg)](https://github.com/serverless/examples/blob/verified/results.json) -The app has a page (`app/page.js`), a route handler at `/api/hello` (`app/api/hello/route.js`) and an image in `public/`. +This example deploys a [Next.js](https://nextjs.org/) 16 app to [AWS Lambda Web Functions](https://docs.aws.amazon.com/lambda/latest/dg/web-functions.html) with one `webApps` entry in `serverless.yml`. A web function runs an HTTP server as it is, so the server that `next build` writes with `output: 'standalone'` runs unchanged: no adapter, no handler. Pages, route handlers and static assets are all served from one public HTTPS endpoint. + +## What it deploys + +- A Lambda web function, `aws-node-nextjs-web-app--site`, that runs the Next.js standalone server on Node.js 24 and arm64, with a revision that holds the built app. +- A public HTTPS endpoint for the web function, `https://..lambda-web..on.aws`, that serves the page (`app/page.js`), the route handler at `/api/hello` (`app/api/hello/route.js`) and the files in `public/` and `.next/static/`. +- An IAM role for the web function, and two CloudWatch Logs log groups: `/aws/lambda/web/aws-node-nextjs-web-app--site` and the same name ending in `.local`. + +## Prerequisites + +- [Node.js](https://nodejs.org/) 24 or later. Web functions run Node.js 24. +- The Serverless Framework CLI: `npm i -g serverless`. See [Getting started](https://www.serverless.com/framework/docs/getting-started). +- An AWS account, with credentials configured on your machine. See [AWS credentials](https://www.serverless.com/framework/docs/providers/aws/guide/credentials). +- A Serverless account, or a license key in `SERVERLESS_LICENSE_KEY`. The CLI asks you to sign in the first time you run it. + +## Deploy + +Install the dependencies, build the app, and deploy from this directory: + +```bash +npm install +npm run build +serverless deploy +``` + +The deploy ships what is in `.next/standalone/`, so run `npm run build` again before every deploy: without it, a deploy ships the previous build. + +Without options, the deploy uses the stage `dev` and the Region `us-east-1`. To change them, pass `--stage` or `--region`, and pass the same options to every later command, including `serverless remove`. + +You should see output like this: + +```text +Deploying "aws-node-nextjs-web-app" to stage "dev" (us-east-1) + +✔ Service deployed to stack aws-node-nextjs-web-app-dev (51s) +endpoint: https://xxxxxxxxxxxxxxxx.xxx.lambda-web.us-east-1.on.aws +``` + +`endpoint` is the app's URL. `serverless info` prints it again later. The endpoint is public: anyone with the URL can open it. + +## Try it + +Open the URL the deploy printed in a browser to see the page, with its image and styles. The route handler answers JSON: + +```bash +curl https://xxxxxxxxxxxxxxxx.xxx.lambda-web.us-east-1.on.aws/api/hello +``` + +```json +{"message":"Hello from a Next.js route handler!","time":"2026-11-25T22:13:39.682Z"} +``` + +The image the page shows comes from `public/`, served by the same server: + +```bash +curl https://xxxxxxxxxxxxxxxx.xxx.lambda-web.us-east-1.on.aws/lambda.svg +``` + +```text + + + ... +``` + +`serverless invoke --web-app` sends the same request without the URL at hand, and prints the status, the headers and the body: + +```bash +serverless invoke --web-app site --path /api/hello +``` + +```text +HTTP 200 OK +content-encoding: gzip +content-type: application/json +date: Wed, 25 Nov 2026 22:13:44 GMT +lambda-web-logstream: 2026/11/25/aws-node-nextjs-web-app-dev-site[rev-xxxxx]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +lambda-web-request-id: XXXXXXXXXXXXXXXXXXXXXXXXXX +vary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch, Accept-Encoding + +{"message":"Hello from a Next.js route handler!","time":"2026-11-25T22:13:45.499Z"} +``` + +A status of 400 or above makes the command exit with code 1, so it also works as a check after a deploy. ## How it works -[`next.config.mjs`](next.config.mjs) sets [`output: 'standalone'`](https://nextjs.org/docs/app/api-reference/config/next-config-js/output). `next build` then writes `.next/standalone/`: a `server.js` that starts the Next.js server, and only the files from `node_modules` that it needs. The standalone output leaves out `public/` and `.next/static/`, so the `build` script in `package.json` copies them in, as the Next.js docs describe, and the server serves them itself: +[`next.config.mjs`](https://github.com/serverless/examples/blob/v4/aws-node-nextjs-web-app/next.config.mjs) sets [`output: 'standalone'`](https://nextjs.org/docs/app/api-reference/config/next-config-js/output). `next build` then writes `.next/standalone/`: a `server.js` that starts the Next.js server, and only the files from `node_modules` that it needs. The standalone output leaves out `public/` and `.next/static/`, so the `build` script in [`package.json`](https://github.com/serverless/examples/blob/v4/aws-node-nextjs-web-app/package.json) copies them in, as the Next.js docs describe, and the server serves them itself: ```bash next build && cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/ @@ -26,7 +108,7 @@ next build && cp -r public .next/standalone/ && cp -r .next/static .next/standal `next.config.mjs` also sets `outputFileTracingRoot` and `turbopack.root` to the project directory, so `server.js` lands at `.next/standalone/server.js` even when a parent directory has its own lockfile. -[`serverless.yml`](serverless.yml) deploys that directory: +[`serverless.yml`](https://github.com/serverless/examples/blob/v4/aws-node-nextjs-web-app/serverless.yml) deploys that directory: ```yaml webApps: @@ -39,34 +121,31 @@ webApps: - '.next/standalone/**' ``` -- `entry` is the file that starts the server. +- `site` is the web app's name, and `entry` is the file that starts the server. - `build: false` ships the built output as it is, without bundling it again. - `package.patterns` puts only `.next/standalone/` in the deployed zip. -The Next.js server reads `PORT` and `HOSTNAME`. The Framework sets both from the address the runtime gives the server to listen on, before `server.js` starts. +The Next.js server reads `PORT` and `HOSTNAME`. The Framework sets both from the address Lambda gives the server to listen on, before `server.js` starts. -On `serverless deploy`, the Framework uploads the zip to the deployment bucket and creates the web function, a revision that runs this code, a public HTTPS endpoint, and the log groups the web function writes to, `/aws/lambda/web/aws-node-nextjs-web-app--site` and the same name ending in `.local`. +On `serverless deploy`, the Framework uploads the zip to the deployment bucket and creates the web function, a revision that runs this code, the public endpoint, the stack output `SiteWebFunctionUrl` with the endpoint's URL, and the log groups the web function writes to. Lambda sends many concurrent requests to each execution environment, so keep per-request state in the request, not in module-level variables. -## Requirements +### Run it locally -- Node.js 24. Web functions run Node.js 24. -- AWS credentials, and a Serverless Framework sign-in (`serverless login`). - -## Develop locally +`next dev` runs the app with hot reload on : ```bash -npm install npm run dev ``` -Open . To run the production build locally: +To run the production build that the deploy ships: ```bash npm run build npm start +curl http://localhost:3000/api/hello ``` -## Develop with `serverless dev` +### Develop with `serverless dev` After the first deploy, `serverless dev` runs the app on your machine with its cloud context: @@ -81,76 +160,40 @@ serverless dev Stop the session with Ctrl+C: the real URL goes back to the deployed build. See [Dev Mode](https://www.serverless.com/framework/docs/providers/aws/guide/dev-mode#web-apps) for the details. -## Build and deploy - -Build first. The deploy ships what is in `.next/standalone/`, so run the build again before every deploy: - -```bash -npm install -npm run build -serverless deploy -``` - -```text -Deploying "aws-node-nextjs-web-app" to stage "dev" (us-east-1) - -✔ Service deployed to stack aws-node-nextjs-web-app-dev (60s) -endpoint: https://xxxxxxxxxxxxxxxx.xxx.lambda-web.us-east-1.on.aws -``` - -`endpoint` is the app's URL. `serverless info` prints it again later. The endpoint is public: anyone with the URL can open it. - -## Call the app - -Open the URL in a browser to see the page, with its image and styles. The route handler answers JSON: - -```bash -curl https://xxxxxxxxxxxxxxxx.xxx.lambda-web.us-east-1.on.aws/api/hello -``` - -```json -{ "message": "Hello from a Next.js route handler!", "time": "2026-10-15T07:09:36.742Z" } -``` +### Logs -`serverless invoke --web-app` sends the same request without the URL at hand, and prints the status and headers before the body: +`serverless logs --web-app` prints what the Next.js server writes, together with Lambda's own lines about starting it and serving requests: ```bash -serverless invoke --web-app site --path /api/hello +serverless logs --web-app site ``` ```text -HTTP 200 OK -content-type: application/json -date: Thu, 15 Oct 2026 08:35:17 GMT -lambda-web-logstream: 2026/10/15/aws-node-nextjs-web-app-dev-site[rev-54poo]85e4e4348714497c8eb5377b7ff32bf7 -lambda-web-request-id: RPZDQOULNKAB7NVDSZXVYLO3S4 -transfer-encoding: chunked -vary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch - -{"message":"Hello from a Next.js route handler!","time":"2026-10-15T08:35:17.826Z"} +{"timestamp":"2026-11-25T22:13:39.517Z","level":"INFO","message":"▲ Next.js 16.4.6","region":"us-east-1"} +{"timestamp":"2026-11-25T22:13:39.518Z","level":"INFO","message":"- Local: http://localhost:3000","region":"us-east-1"} +{"timestamp":"2026-11-25T22:13:39.518Z","level":"INFO","message":"- Network: http://0.0.0.0:3000","region":"us-east-1"} +{"timestamp":"2026-11-25T22:13:39.518Z","level":"INFO","message":"✓ Ready in 0ms","region":"us-east-1"} +{"timestamp":"2026-11-25T22:13:39.524Z","level":"INFO","type":"platform.initReport","region":"us-east-1","record":{"status":"success","revisionId":"rev-xxxxx","instanceId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","initializationType":"native-http","metrics":{"totalDurationMs":584.000,"totalCpuTimeMs":341.000,"maxMemoryUsageMb":170}}} ``` -A status of 400 or above makes the command exit with code 1, so it also works as a check after a deploy. +Add `--tail` to follow new lines as they arrive. -## Logs +## Cost and cleanup -`serverless logs --web-app` prints what the Next.js server writes, together with Lambda's own lines about starting it and serving requests: +While the example is deployed, Lambda bills each request to the web function, the CPU time the server uses, and the memory each execution environment uses while it runs. CloudWatch Logs bills for the log data it stores, and Amazon S3 for the uploaded code in the deployment bucket. See [Lambda pricing](https://aws.amazon.com/lambda/pricing/), [CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/) and [S3 pricing](https://aws.amazon.com/s3/pricing/). Remove the stack, with the web function, its endpoint, its role and its log groups, when you are done: ```bash -serverless logs --web-app site +serverless remove ``` ```text -{"timestamp":"2026-10-16T19:01:54.955Z","level":"INFO","message":"▲ Next.js 16.4.0","region":"us-east-1"} -{"timestamp":"2026-10-16T19:01:54.958Z","level":"INFO","message":"- Local: http://localhost:3000","region":"us-east-1"} -{"timestamp":"2026-10-16T19:01:54.958Z","level":"INFO","message":"- Network: http://0.0.0.0:3000","region":"us-east-1"} -{"timestamp":"2026-10-16T19:01:54.958Z","level":"INFO","message":"✓ Ready in 0ms","region":"us-east-1"} +Removing "aws-node-nextjs-web-app" from stage "dev" (us-east-1) +✔ Service aws-node-nextjs-web-app has been successfully removed (28s) ``` -## Remove - -```bash -serverless remove -``` +## Next steps -This deletes the stack, with the web function, its endpoint and its log groups, and the uploaded code. +- Read the [Web Apps docs](https://www.serverless.com/framework/docs/providers/aws/guide/web-apps) for TypeScript, environment variables, IAM, VPC access, scaling limits and IAM-authorized endpoints. +- Deploy a plain Node.js server with the [Express web app example](https://github.com/serverless/examples/tree/v4/aws-node-express-web-app). +- Serve a frontend and an API from one domain with the [web apps on a custom domain example](https://github.com/serverless/examples/tree/v4/aws-node-web-app-custom-domain). +- Read how Next.js builds the [standalone output](https://nextjs.org/docs/app/api-reference/config/next-config-js/output) and what it leaves out. diff --git a/aws-node-nextjs-web-app/example.json b/aws-node-nextjs-web-app/example.json new file mode 100644 index 000000000..cffb0d72a --- /dev/null +++ b/aws-node-nextjs-web-app/example.json @@ -0,0 +1,41 @@ +{ + "title": "Next.js app on AWS Lambda Web Functions", + "description": "This example deploys a Next.js app to AWS Lambda Web Functions with the Serverless Framework, using the standalone server that next build writes. Pages, route handlers and static assets are all served from one public HTTPS endpoint.", + "language": "node", + "platform": "AWS", + "framework": "v4", + "author": { + "name": "Serverless, Inc.", + "link": "https://github.com/serverless", + "avatar": "https://avatars1.githubusercontent.com/u/13742415?s=200&v=4" + }, + "services": [ + "lambda", + "iam", + "logs" + ], + "test": { + "tier": "fast", + "prepare": { + "path": "test/prepare.mjs" + }, + "checks": [ + { + "http": { + "output": "SiteWebFunctionUrl", + "path": "/api/hello", + "status": 200, + "contains": "Hello from a Next.js route handler!" + } + }, + { + "http": { + "output": "SiteWebFunctionUrl", + "path": "/lambda.svg", + "status": 200, + "contains": "fill=\"#fd5750\"" + } + } + ] + } +} diff --git a/aws-node-nextjs-web-app/package-lock.json b/aws-node-nextjs-web-app/package-lock.json index acab34c8c..ffed79919 100644 --- a/aws-node-nextjs-web-app/package-lock.json +++ b/aws-node-nextjs-web-app/package-lock.json @@ -8,9 +8,9 @@ "name": "aws-node-nextjs-web-app", "version": "1.0.0", "dependencies": { - "next": "^16.4.0", - "react": "^19.3.0", - "react-dom": "^19.3.0" + "next": "16.4.6", + "react": "19.3.1", + "react-dom": "19.3.1" } }, "node_modules/@emnapi/runtime": { @@ -573,15 +573,15 @@ } }, "node_modules/@next/env": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.0.tgz", - "integrity": "sha512-pyLlT5oafGlX8X7xjgGNXz5dNIDSxREm+qD6i9VLSZiZFopA/XWl8NM/KPmLx/8EG/++c49iid3gNWSQW1+2dQ==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz", + "integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==", "license": "MIT" }, "node_modules/@next/swc-darwin-arm64": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.0.tgz", - "integrity": "sha512-yyZ+9MgViAKLLb5l1gPBGjRwnq3teNLb5Zx6JEw8LzNSTjlsnp+baUHFxTgl7PpjCmKf48VQfyipG1eBflb48Q==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz", + "integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==", "cpu": [ "arm64" ], @@ -595,9 +595,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.0.tgz", - "integrity": "sha512-RePEEejEj1Auf5s9qEcG0JbcDP3ceNUS/ofNX8AhxzgIjTVlZIHMatlp16YplcSMpsVo/ZMQHJTjbMYJznjGUg==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz", + "integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==", "cpu": [ "x64" ], @@ -611,9 +611,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.0.tgz", - "integrity": "sha512-HhsyCqd+NpmvDDVY/LqkAN24f+QVvXh3ie+PfcwKinWL2Mu826JymQxJXGjAIfmJ4VlHjp4Pe/nZtXtUoEMAqw==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz", + "integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==", "cpu": [ "arm64" ], @@ -630,9 +630,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.0.tgz", - "integrity": "sha512-sN9Pf+Zh+RpZAOmbR7d8KAA8T61CVhawtbEJ2Bk6QrRzx6Z/6haaF4UiwBzytM96GRRRWZh9/WALIEO3npMamA==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz", + "integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==", "cpu": [ "arm64" ], @@ -649,9 +649,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.0.tgz", - "integrity": "sha512-D5M5xLWQVd1CvR+L7BickM1weRfmM41x3L1NWcnKY/oyJJqr1qwaCgmu3dMAhLBOMdZwSuDCRV6DJRRpiUkbDQ==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz", + "integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==", "cpu": [ "x64" ], @@ -668,9 +668,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.0.tgz", - "integrity": "sha512-8d5WLS6a9YalqpOgXdlbvonFu+sIgjA+CO6tGzetrpPVcUL56foa7B7664h41rAlbLi5fJwK4vWji3zf4QDy+w==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz", + "integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==", "cpu": [ "x64" ], @@ -687,9 +687,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.0.tgz", - "integrity": "sha512-sQuOIiW3snb48UwrBcDMvFA/u03qtw2LeuSIxFIQ9AJuW9UG/4Ddsfo+eV73PnZwBhyncMtsKVh7PrzMol2/fA==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz", + "integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==", "cpu": [ "arm64" ], @@ -703,9 +703,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.0.tgz", - "integrity": "sha512-6/33lCuxpdHUy27RegyGM/5uTpF7YZd3UR4D0gpkOA/tWY5YR7msbQjqPgCZmSmxrrTLGCXYA4A8vT2H5DPGTQ==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz", + "integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==", "cpu": [ "x64" ], @@ -794,12 +794,12 @@ } }, "node_modules/next": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/next/-/next-16.4.0.tgz", - "integrity": "sha512-N2C+9q89Z/oLrsepSRS4jRMtwmUZAoZuAHU0e9T6+sAB5DdhADmrnOW+zjYijlrYFmVfmQhGVGy9eMFoB7UgKg==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz", + "integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==", "license": "MIT", "dependencies": { - "@next/env": "16.4.0", + "@next/env": "16.4.6", "@swc/helpers": "0.5.23", "baseline-browser-mapping": "^2.9.19", "caniuse-lite": "^1.0.30001579", @@ -813,15 +813,15 @@ "node": ">=20.9.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "16.4.0", - "@next/swc-darwin-x64": "16.4.0", - "@next/swc-linux-arm64-gnu": "16.4.0", - "@next/swc-linux-arm64-musl": "16.4.0", - "@next/swc-linux-x64-gnu": "16.4.0", - "@next/swc-linux-x64-musl": "16.4.0", - "@next/swc-win32-arm64-msvc": "16.4.0", - "@next/swc-win32-x64-msvc": "16.4.0", - "sharp": "^0.35.4" + "@next/swc-darwin-arm64": "16.4.6", + "@next/swc-darwin-x64": "16.4.6", + "@next/swc-linux-arm64-gnu": "16.4.6", + "@next/swc-linux-arm64-musl": "16.4.6", + "@next/swc-linux-x64-gnu": "16.4.6", + "@next/swc-linux-x64-musl": "16.4.6", + "@next/swc-win32-arm64-msvc": "16.4.6", + "@next/swc-win32-x64-msvc": "16.4.6", + "sharp": "^0.35.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -881,24 +881,24 @@ } }, "node_modules/react": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz", - "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/react-dom": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz", - "integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", "license": "MIT", "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { - "react": "^19.3.0" + "react": "^19.3.1" } }, "node_modules/scheduler": { diff --git a/aws-node-nextjs-web-app/package.json b/aws-node-nextjs-web-app/package.json index 9f4ab25da..973bc9fa3 100644 --- a/aws-node-nextjs-web-app/package.json +++ b/aws-node-nextjs-web-app/package.json @@ -9,8 +9,8 @@ "start": "node .next/standalone/server.js" }, "dependencies": { - "next": "^16.4.0", - "react": "^19.3.0", - "react-dom": "^19.3.0" + "next": "16.4.6", + "react": "19.3.1", + "react-dom": "19.3.1" } } diff --git a/aws-node-nextjs-web-app/test/prepare.mjs b/aws-node-nextjs-web-app/test/prepare.mjs new file mode 100644 index 000000000..1752ec83f --- /dev/null +++ b/aws-node-nextjs-web-app/test/prepare.mjs @@ -0,0 +1,14 @@ +// Runs before the live test's deploy: what README.md → Deploy does before +// `serverless deploy`. Builds the Next.js standalone server into +// .next/standalone/, the directory serverless.yml deploys. +// +// Run by the example test runner in the example copy, after `npm ci`. + +import { execFileSync } from 'node:child_process'; + +try { + execFileSync('npm', ['run', 'build'], { stdio: ['ignore', 'inherit', 'inherit'] }); +} catch (err) { + console.error(`npm run build: ${err.message}`); + process.exit(1); +}