Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ A zero configuration Nextjs 9.0 [serverless component](https://github.com/server
- [Design principles](#design-principles)
- [Features](#features)
- [Getting started](#getting-started)
- [Lambda@Edge configuration](#lambda-at-edge-configuration)
- [Custom domain name](#custom-domain-name)
- [AWS Permissions](#aws-permissions)
- [Architecture](#architecture)
Expand Down Expand Up @@ -133,8 +134,9 @@ myNextApplication:

Make sure you add CloudWatch log permissions to your custom policy.

### Lambda memory
Both **default** and **api** lambdas will be assigned 512mb of memory by default. This value can be altered by assigning a number to the `memory` input
### Lambda At Edge Configuration

Both **default** and **api** edge lambdas will be assigned 512mb of memory by default. This value can be altered by assigning a number to the `memory` input

```yml
# serverless.yml
Expand All @@ -158,6 +160,21 @@ myNextApplication:
apiLambda: 2048
```

Similarly, the timeout by default is 10 seconds. To customise you can:

```yml
# serverless.yml

myNextApplication:
component: serverless-next.js
inputs:
timeout:
defaultLambda: 20
apiLambda: 15
```

Note the maximum timeout allowed for Lambda@Edge is 30 seconds. See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-requirements-limits.html

### Architecture

![architecture](./arch_no_grid.png)
Expand All @@ -180,19 +197,20 @@ The fourth cache behaviour handles next API requests `api/*`.

### Inputs

| Name | Type | Default Value | Description |
| ------------- | --------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| domain | `Array` | `null` | For example `['admin', 'portal.com']`. |
| bucketName | `string` | `null` | Custom bucket name where static assets are stored. By default is autogenerated. |
| nextConfigDir | `string` | `./` | Directory where your application `next.config.js` file is. This input is useful when the `serverless.yml` is not in the same directory as the next app. <br>**Note:** `nextConfigDir` should be set if `next.config.js` `distDir` is used. |
| nextStaticDir | `string` | `./` | If your `static` or `public` directory is not a direct child of `nextConfigDir` this is needed. |
| memory | `number` or `object` | `512` | When assigned a number, both the default and api lambdas will assigned memory of that value. When assigned to an object, values for the default and api lambdas can be separately defined | |
| build | `boolean` or `Object` | `true` | When true builds and deploys app, when false assume the app has been built and uses the `.next` `.serverless_nextjs` directories in `nextConfigDir` to deploy. If an object is passed `build` allows for overriding what script gets called and with what arguments. |
| build.cmd | `string` | `node_modules/.bin/next` | Build command |
| build.args | `Array|string` | `['build']` | Arguments to pass to the build |
| build.cwd | `string` | `./` | Override the current working directory |
| build.enabled | `boolean` | `true` | Same as passing `build:false` but from within the config. |
| build.env | `Object` | `{}` | Add additional environment variables to the script. |
| Name | Type | Default Value | Description |
| ------------- | ----------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| domain | `Array` | `null` | For example `['admin', 'portal.com']` |
| bucketName | `string` | `null` | Custom bucket name where static assets are stored. By default is autogenerated. |
| nextConfigDir | `string` | `./` | Directory where your application `next.config.js` file is. This input is useful when the `serverless.yml` is not in the same directory as the next app. <br>**Note:** `nextConfigDir` should be set if `next.config.js` `distDir` is used |
| nextStaticDir | `string` | `./` | If your `static` or `public` directory is not a direct child of `nextConfigDir` this is needed |
| memory | `number\|object` | `512` | When assigned a number, both the default and api lambdas will assigned memory of that value. When assigned to an object, values for the default and api lambdas can be separately defined | |
| timeout | `number\|object` | `10` | Same as above |
| build | `boolean\|object` | `true` | When true builds and deploys app, when false assume the app has been built and uses the `.next` `.serverless_nextjs` directories in `nextConfigDir` to deploy. If an object is passed `build` allows for overriding what script gets called and with what arguments. |
| build.cmd | `string` | `node_modules/.bin/next` | Build command |
| build.args | `Array\|string` | `['build']` | Arguments to pass to the build |
| build.cwd | `string` | `./` | Override the current working directory |
| build.enabled | `boolean` | `true` | Same as passing `build:false` but from within the config |
| build.env | `object` | `{}` | Add additional environment variables to the script |

Custom inputs can be configured like this:

Expand Down Expand Up @@ -310,4 +328,3 @@ Support this project with your organization. Your logo will show up here with a
<a href="https://opencollective.com/serverless-nextjs-plugin/organization/7/website"><img src="https://opencollective.com/serverless-nextjs-plugin/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/serverless-nextjs-plugin/organization/8/website"><img src="https://opencollective.com/serverless-nextjs-plugin/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/serverless-nextjs-plugin/organization/9/website"><img src="https://opencollective.com/serverless-nextjs-plugin/organization/9/avatar.svg"></a>

Loading