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

Commit 7fbc629

Browse files
authored
docs: readme improved (#16)
Co-authored-by: Jan Soukup <[email protected]>
1 parent 458798e commit 7fbc629

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

Diff for: README.md

+31-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ And includes CLI and custom server handler to integrate with ApiGw.
66

77
- [NextJS Lambda Utils](#nextjs-lambda-utils)
88
- [Usage](#usage)
9+
- [next.config.js](#nextconfigjs)
910
- [Server handler](#server-handler)
1011
- [Image handler](#image-handler)
1112
- [CDK](#cdk)
@@ -14,6 +15,7 @@ And includes CLI and custom server handler to integrate with ApiGw.
1415
- [Server handler](#server-handler-1)
1516
- [Static assets](#static-assets)
1617
- [TODO](#todo)
18+
- [Disclaimer](#disclaimer)
1719

1820
## Usage
1921

@@ -23,6 +25,19 @@ This division makes it easier to control resources and specify sizes and timeout
2325

2426
Loading of assets and static content is handled via Cloudfront and S3 origin, so there is no need for specifying this behaviour in Lambda or handling it anyhow.
2527

28+
### next.config.js
29+
30+
The only requirement is to change your Next12 config to produce standalone output via `output: 'standalone'`.
31+
This should work fine for single-repositories with yarn/npm/pnpm.
32+
33+
In case you are using monorepo/workspaces, be aware! Producing standalone build is tricky due to dependencies being spread out and not contained within single `node_modules` folder, making it complicated for `SWC` to properly produce required dependencies. This would most likely result in deployment failing with HTTP 500, internal error, as some required dependency is not in place.
34+
35+
See:
36+
37+
- https://github.com/vercel/next.js/issues/36386
38+
- https://github.com/vercel/next.js/discussions/32223
39+
-
40+
2641
### Server handler
2742

2843
```
@@ -35,14 +50,14 @@ Create new lambda function with NODE_16 runtime in AWS.
3550

3651
```
3752
const dependenciesLayer = new LayerVersion(this, 'DepsLayer', {
38-
code: Code.fromAsset(`next.out/dependenciesLayer.zip`),
39-
})
53+
code: Code.fromAsset(`next.out/dependenciesLayer.zip`),
54+
})
4055
41-
const imageOptimizerFn = new Function(this, 'LambdaFunction', {
56+
const requestHandlerFn = new Function(this, 'LambdaFunction', {
4257
code: Code.fromAsset(`next.out/code.zip`, { followSymlinks: SymlinkFollowMode.NEVER }),
4358
runtime: Runtime.NODEJS_16_X,
4459
handler: 'handler.handler',
45-
re layers: [dependenciesLayer],
60+
layers: [dependenciesLayer],
4661
memorySize: 512,
4762
timeout: Duration.seconds(10),
4863
})
@@ -273,3 +288,15 @@ Cloudfront paths used:
273288
- Use lib/index.ts as single entry and export all paths/functions from it (including zip paths).
274289
- Consider using \*.svg, \*.png, \*.jpeg etc. as routing rule for Cloudfront to distinguish between assets and pages.
275290
- Add command for guessing version bumps from git commits & keywords, existing solutions are horendously huge, we just need a simple version bumping.
291+
292+
# Disclaimer
293+
294+
At this point, advanced features were not tested with this setup. This includes:
295+
296+
- `GetServerSideProps`,
297+
- middleware,
298+
- ISR and fallbacks,
299+
- streaming,
300+
- custom babel configuration.
301+
302+
I am looking for advanced projects implementing those features, so we can test them out! Reach out to me!

0 commit comments

Comments
 (0)