Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 3d1b3d3

Browse files
docs: update assets bucket section
1 parent 1c417f3 commit 3d1b3d3

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The plugin targets [Next 8 serverless mode](https://nextjs.org/blog/next-8/#serv
1616

1717
- [Motivation](#motivation)
1818
- [Getting Started](#getting-started)
19-
- [Next config](#next-configuration)
19+
- [Hosting static assets](#hosting-static-assets)
2020
- [Deploying](#deploying)
2121
- [Deploying a single page](#deploying-a-single-page)
2222
- [Overriding page configuration](#overriding-page-configuration)
@@ -84,17 +84,35 @@ package:
8484
8585
You can exclude everything. The plugin makes sure the page handlers are included in the artifacts.
8686
87-
## Next configuration
87+
## Hosting static assets
88+
89+
If you don't want to manage uploading the next static assets yourself, like uploading them to a CDN, the plugin can do this for you by hosting the asset files on S3.
90+
91+
The easiest way is to use a [valid bucket URL](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro) in the `assetPrefix` field of your next configuration:
8892

8993
```js
94+
// next.config.js
9095
module.exports = {
9196
assetPrefix: "https://s3.amazonaws.com/your-bucket-name"
9297
};
9398
```
9499

95-
| Config Key | Description |
96-
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
97-
| assetPrefix _(Optional)_ | When using a [valid bucket URL](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro) the plugin will create a new S3 Bucket using the parsed name. On deployment, static assets will be uploaded to the bucket provisioned. |
100+
The plugin will create a new S3 Bucket using the parsed name. On deployment, static assets will be uploaded to the bucket provisioned.
101+
102+
Alternatively, if you just want the assets to get uploaded to S3, you can provide the bucket name via the plugin config:
103+
104+
```yml
105+
# serverless.yml
106+
plugins:
107+
- serverless-nextjs-plugin
108+
109+
custom:
110+
serverless-nextjs:
111+
nextConfigDir: "./"
112+
assetsBucketName: "your-bucket-name"
113+
```
114+
115+
With this approach you could have a CloudFront distribution in front of the bucket and use a custom domain in the assetPrefix.
98116

99117
## Deploying
100118

0 commit comments

Comments
 (0)