cdk-nextjs 0.5.15 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.jsii +821 -253
  2. package/.jsii.tabl.json +1 -1
  3. package/API.md +787 -18
  4. package/README.md +3 -3
  5. package/docs/breaking-changes.md +86 -0
  6. package/docs/caching-guide.md +6 -0
  7. package/docs/plans/adapter-runtime-release.md +362 -0
  8. package/docs/plans/phase-0-image-function-opt-in.md +295 -0
  9. package/lib/generated-structs/OptionalNextjsDistributionProps.d.ts +13 -0
  10. package/lib/generated-structs/OptionalNextjsDistributionProps.js +1 -1
  11. package/lib/image-optimization/handler-utils.d.ts +34 -0
  12. package/lib/image-optimization/handler-utils.js +83 -0
  13. package/lib/image-optimization/handler-utils.test.d.ts +1 -0
  14. package/lib/image-optimization/handler-utils.test.js +178 -0
  15. package/lib/image-optimization/handler.mjs +56126 -0
  16. package/lib/index.d.ts +2 -1
  17. package/lib/index.js +4 -2
  18. package/lib/nextjs-api.d.ts +44 -0
  19. package/lib/nextjs-api.js +64 -20
  20. package/lib/nextjs-api.test.d.ts +1 -0
  21. package/lib/nextjs-api.test.js +144 -0
  22. package/lib/nextjs-build/nextjs-build.d.ts +60 -0
  23. package/lib/nextjs-build/nextjs-build.js +184 -27
  24. package/lib/nextjs-cache.js +1 -1
  25. package/lib/nextjs-compute/nextjs-containers.js +1 -1
  26. package/lib/nextjs-compute/nextjs-functions.js +1 -1
  27. package/lib/nextjs-compute/nextjs-image-function.d.ts +53 -0
  28. package/lib/nextjs-compute/nextjs-image-function.js +59 -0
  29. package/lib/nextjs-distribution.d.ts +33 -0
  30. package/lib/nextjs-distribution.js +39 -11
  31. package/lib/nextjs-post-deploy.js +1 -1
  32. package/lib/nextjs-static-assets.d.ts +18 -0
  33. package/lib/nextjs-static-assets.js +33 -6
  34. package/lib/nextjs-static-assets.test.d.ts +1 -0
  35. package/lib/nextjs-static-assets.test.js +58 -0
  36. package/lib/root-constructs/nextjs-base-construct.d.ts +62 -2
  37. package/lib/root-constructs/nextjs-base-construct.js +81 -3
  38. package/lib/root-constructs/nextjs-global-containers.d.ts +6 -1
  39. package/lib/root-constructs/nextjs-global-containers.js +11 -5
  40. package/lib/root-constructs/nextjs-global-functions.d.ts +16 -5
  41. package/lib/root-constructs/nextjs-global-functions.js +23 -21
  42. package/lib/root-constructs/nextjs-regional-containers.js +1 -1
  43. package/lib/root-constructs/nextjs-regional-functions.d.ts +11 -5
  44. package/lib/root-constructs/nextjs-regional-functions.js +17 -21
  45. package/lib/utils/base-path.d.ts +40 -0
  46. package/lib/utils/base-path.js +123 -0
  47. package/lib/utils/base-path.test.d.ts +1 -0
  48. package/lib/utils/base-path.test.js +163 -0
  49. package/lib/utils/experimental-flags.d.ts +24 -0
  50. package/lib/utils/experimental-flags.js +30 -0
  51. package/lib/utils/get-architecture.d.ts +10 -0
  52. package/lib/utils/get-architecture.js +17 -2
  53. package/package.json +3 -1
package/API.md CHANGED
@@ -124,6 +124,7 @@ Any object.
124
124
  | --- | --- | --- |
125
125
  | <code><a href="#cdk-nextjs.NextjsApi.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
126
126
  | <code><a href="#cdk-nextjs.NextjsApi.property.api">api</a></code> | <code>aws-cdk-lib.aws_apigateway.RestApi</code> | The API Gateway REST API. |
127
+ | <code><a href="#cdk-nextjs.NextjsApi.property.url">url</a></code> | <code>string</code> | Public URL of the app, including every path segment the API nests it under. |
127
128
 
128
129
  ---
129
130
 
@@ -151,6 +152,25 @@ The API Gateway REST API.
151
152
 
152
153
  ---
153
154
 
155
+ ##### `url`<sup>Required</sup> <a name="url" id="cdk-nextjs.NextjsApi.property.url"></a>
156
+
157
+ ```typescript
158
+ public readonly url: string;
159
+ ```
160
+
161
+ - *Type:* string
162
+
163
+ Public URL of the app, including every path segment the API nests it under.
164
+
165
+ Prefers a custom domain configured through `overrides.restApiProps.domainName`
166
+ over the execute-api endpoint.
167
+
168
+ A domain attached after this construct is created (`api.addDomainName()`) is
169
+ still used for the host, but CDK keeps its base path mappings private, so a
170
+ mapping added that way won't show up here.
171
+
172
+ ---
173
+
154
174
 
155
175
  ### NextjsBaseConstruct <a name="NextjsBaseConstruct" id="cdk-nextjs.NextjsBaseConstruct"></a>
156
176
 
@@ -466,9 +486,11 @@ Any object.
466
486
  | <code><a href="#cdk-nextjs.NextjsBuild.property.buildId">buildId</a></code> | <code>string</code> | Unique id for Next.js build. Used to partition cache storage and as metadata for static assets in S3 bucket. |
467
487
  | <code><a href="#cdk-nextjs.NextjsBuild.property.dotNextPath">dotNextPath</a></code> | <code>string</code> | Absolute path to the .next directory containing Next.js build artifacts. |
468
488
  | <code><a href="#cdk-nextjs.NextjsBuild.property.initCacheDir">initCacheDir</a></code> | <code>string</code> | Absolute path to the init cache directory. |
489
+ | <code><a href="#cdk-nextjs.NextjsBuild.property.nextConfigBasePath">nextConfigBasePath</a></code> | <code>string</code> | The Next.js app's own `basePath` — the URL prefix it generates its links and asset hrefs under — read out of the build's `required-server-files.json`. Normalized to a bare path segment, empty when the app sets none. Exposed so root constructs can reconcile it with the CDK `basePath` prop, which is a distinct thing; see `resolveBasePath`. |
469
490
  | <code><a href="#cdk-nextjs.NextjsBuild.property.publicDirEntries">publicDirEntries</a></code> | <code><a href="#cdk-nextjs.PublicDirEntry">PublicDirEntry</a>[]</code> | Absolute path to public. |
470
491
  | <code><a href="#cdk-nextjs.NextjsBuild.property.relativePathToEntrypoint">relativePathToEntrypoint</a></code> | <code>string</code> | The entrypoint JavaScript file used as an argument for Node.js to run the Next.js standalone server relative to the standalone directory. |
471
492
  | <code><a href="#cdk-nextjs.NextjsBuild.property.relativePathToPackage">relativePathToPackage</a></code> | <code>string</code> | Relative path from the standalone directory to the package containing the Next.js app. This is automatically detected from the standalone build output. |
493
+ | <code><a href="#cdk-nextjs.NextjsBuild.property.imageOptimizationAssetPath">imageOptimizationAssetPath</a></code> | <code>string</code> | Absolute path to the directory prepared for the image optimization Lambda asset: bundled handler, glibc `sharp` binaries, and `required-server-files.json`. Only set for {@link NextjsType.GLOBAL_FUNCTIONS} and {@link NextjsType.REGIONAL_FUNCTIONS}, and only when the dedicated image optimization Lambda is enabled. |
472
494
 
473
495
  ---
474
496
 
@@ -527,6 +549,18 @@ Absolute path to the init cache directory.
527
549
  ```
528
550
 
529
551
 
552
+ ##### `nextConfigBasePath`<sup>Required</sup> <a name="nextConfigBasePath" id="cdk-nextjs.NextjsBuild.property.nextConfigBasePath"></a>
553
+
554
+ ```typescript
555
+ public readonly nextConfigBasePath: string;
556
+ ```
557
+
558
+ - *Type:* string
559
+
560
+ The Next.js app's own `basePath` — the URL prefix it generates its links and asset hrefs under — read out of the build's `required-server-files.json`. Normalized to a bare path segment, empty when the app sets none. Exposed so root constructs can reconcile it with the CDK `basePath` prop, which is a distinct thing; see `resolveBasePath`.
561
+
562
+ ---
563
+
530
564
  ##### `publicDirEntries`<sup>Required</sup> <a name="publicDirEntries" id="cdk-nextjs.NextjsBuild.property.publicDirEntries"></a>
531
565
 
532
566
  ```typescript
@@ -586,6 +620,18 @@ Relative path from the standalone directory to the package containing the Next.j
586
620
  ```
587
621
 
588
622
 
623
+ ##### `imageOptimizationAssetPath`<sup>Optional</sup> <a name="imageOptimizationAssetPath" id="cdk-nextjs.NextjsBuild.property.imageOptimizationAssetPath"></a>
624
+
625
+ ```typescript
626
+ public readonly imageOptimizationAssetPath: string;
627
+ ```
628
+
629
+ - *Type:* string
630
+
631
+ Absolute path to the directory prepared for the image optimization Lambda asset: bundled handler, glibc `sharp` binaries, and `required-server-files.json`. Only set for {@link NextjsType.GLOBAL_FUNCTIONS} and {@link NextjsType.REGIONAL_FUNCTIONS}, and only when the dedicated image optimization Lambda is enabled.
632
+
633
+ ---
634
+
589
635
 
590
636
  ### NextjsCache <a name="NextjsCache" id="cdk-nextjs.NextjsCache"></a>
591
637
 
@@ -1395,7 +1441,7 @@ Any object.
1395
1441
  | **Name** | **Type** | **Description** |
1396
1442
  | --- | --- | --- |
1397
1443
  | <code><a href="#cdk-nextjs.NextjsGlobalContainers.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
1398
- | <code><a href="#cdk-nextjs.NextjsGlobalContainers.property.url">url</a></code> | <code>string</code> | *No description.* |
1444
+ | <code><a href="#cdk-nextjs.NextjsGlobalContainers.property.url">url</a></code> | <code>string</code> | Public URL of the app, including `basePath` — the app only answers under that prefix, and it's derived from the app's own `basePath` when the prop is left unset, so it's there whether or not you asked for it. |
1399
1445
  | <code><a href="#cdk-nextjs.NextjsGlobalContainers.property.nextjsBuild">nextjsBuild</a></code> | <code><a href="#cdk-nextjs.NextjsBuild">NextjsBuild</a></code> | *No description.* |
1400
1446
  | <code><a href="#cdk-nextjs.NextjsGlobalContainers.property.nextjsCache">nextjsCache</a></code> | <code><a href="#cdk-nextjs.NextjsCache">NextjsCache</a></code> | *No description.* |
1401
1447
  | <code><a href="#cdk-nextjs.NextjsGlobalContainers.property.nextjsStaticAssets">nextjsStaticAssets</a></code> | <code><a href="#cdk-nextjs.NextjsStaticAssets">NextjsStaticAssets</a></code> | *No description.* |
@@ -1425,6 +1471,8 @@ public readonly url: string;
1425
1471
 
1426
1472
  - *Type:* string
1427
1473
 
1474
+ Public URL of the app, including `basePath` — the app only answers under that prefix, and it's derived from the app's own `basePath` when the prop is left unset, so it's there whether or not you asked for it.
1475
+
1428
1476
  ---
1429
1477
 
1430
1478
  ##### `nextjsBuild`<sup>Required</sup> <a name="nextjsBuild" id="cdk-nextjs.NextjsGlobalContainers.property.nextjsBuild"></a>
@@ -1609,13 +1657,14 @@ Any object.
1609
1657
  | **Name** | **Type** | **Description** |
1610
1658
  | --- | --- | --- |
1611
1659
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
1612
- | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.url">url</a></code> | <code>string</code> | *No description.* |
1660
+ | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.url">url</a></code> | <code>string</code> | Public URL of the app, including `basePath` — the app only answers under that prefix, and it's derived from the app's own `basePath` when the prop is left unset, so it's there whether or not you asked for it. |
1613
1661
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsBuild">nextjsBuild</a></code> | <code><a href="#cdk-nextjs.NextjsBuild">NextjsBuild</a></code> | *No description.* |
1614
1662
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsCache">nextjsCache</a></code> | <code><a href="#cdk-nextjs.NextjsCache">NextjsCache</a></code> | *No description.* |
1615
1663
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsStaticAssets">nextjsStaticAssets</a></code> | <code><a href="#cdk-nextjs.NextjsStaticAssets">NextjsStaticAssets</a></code> | *No description.* |
1616
1664
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsDistribution">nextjsDistribution</a></code> | <code><a href="#cdk-nextjs.NextjsDistribution">NextjsDistribution</a></code> | *No description.* |
1617
1665
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsFunctions">nextjsFunctions</a></code> | <code><a href="#cdk-nextjs.NextjsFunctions">NextjsFunctions</a></code> | *No description.* |
1618
1666
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsPostDeploy">nextjsPostDeploy</a></code> | <code><a href="#cdk-nextjs.NextjsPostDeploy">NextjsPostDeploy</a></code> | *No description.* |
1667
+ | <code><a href="#cdk-nextjs.NextjsGlobalFunctions.property.nextjsImageFunction">nextjsImageFunction</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunction">NextjsImageFunction</a></code> | Only created when the (experimental, unsupported) dedicated image optimization Lambda is enabled. |
1619
1668
 
1620
1669
  ---
1621
1670
 
@@ -1639,6 +1688,8 @@ public readonly url: string;
1639
1688
 
1640
1689
  - *Type:* string
1641
1690
 
1691
+ Public URL of the app, including `basePath` — the app only answers under that prefix, and it's derived from the app's own `basePath` when the prop is left unset, so it's there whether or not you asked for it.
1692
+
1642
1693
  ---
1643
1694
 
1644
1695
  ##### `nextjsBuild`<sup>Required</sup> <a name="nextjsBuild" id="cdk-nextjs.NextjsGlobalFunctions.property.nextjsBuild"></a>
@@ -1701,6 +1752,180 @@ public readonly nextjsPostDeploy: NextjsPostDeploy;
1701
1752
 
1702
1753
  ---
1703
1754
 
1755
+ ##### `nextjsImageFunction`<sup>Optional</sup> <a name="nextjsImageFunction" id="cdk-nextjs.NextjsGlobalFunctions.property.nextjsImageFunction"></a>
1756
+
1757
+ ```typescript
1758
+ public readonly nextjsImageFunction: NextjsImageFunction;
1759
+ ```
1760
+
1761
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunction">NextjsImageFunction</a>
1762
+
1763
+ Only created when the (experimental, unsupported) dedicated image optimization Lambda is enabled.
1764
+
1765
+ `_next/image` is otherwise served by
1766
+ {@link nextjsFunctions}.
1767
+
1768
+ ---
1769
+
1770
+
1771
+ ### NextjsImageFunction <a name="NextjsImageFunction" id="cdk-nextjs.NextjsImageFunction"></a>
1772
+
1773
+ Dedicated Lambda function for Next.js image optimization (`src/image-optimization/handler.mts`). Kept separate from the server function so image requests get a lightweight, natively-streaming zip Lambda instead of paying the Docker/Lambda Web Adapter cold-start cost.
1774
+
1775
+ #### Initializers <a name="Initializers" id="cdk-nextjs.NextjsImageFunction.Initializer"></a>
1776
+
1777
+ ```typescript
1778
+ import { NextjsImageFunction } from 'cdk-nextjs'
1779
+
1780
+ new NextjsImageFunction(scope: Construct, id: string, props: NextjsImageFunctionProps)
1781
+ ```
1782
+
1783
+ | **Name** | **Type** | **Description** |
1784
+ | --- | --- | --- |
1785
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | *No description.* |
1786
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.Initializer.parameter.id">id</a></code> | <code>string</code> | *No description.* |
1787
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.Initializer.parameter.props">props</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a></code> | *No description.* |
1788
+
1789
+ ---
1790
+
1791
+ ##### `scope`<sup>Required</sup> <a name="scope" id="cdk-nextjs.NextjsImageFunction.Initializer.parameter.scope"></a>
1792
+
1793
+ - *Type:* constructs.Construct
1794
+
1795
+ ---
1796
+
1797
+ ##### `id`<sup>Required</sup> <a name="id" id="cdk-nextjs.NextjsImageFunction.Initializer.parameter.id"></a>
1798
+
1799
+ - *Type:* string
1800
+
1801
+ ---
1802
+
1803
+ ##### `props`<sup>Required</sup> <a name="props" id="cdk-nextjs.NextjsImageFunction.Initializer.parameter.props"></a>
1804
+
1805
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a>
1806
+
1807
+ ---
1808
+
1809
+ #### Methods <a name="Methods" id="Methods"></a>
1810
+
1811
+ | **Name** | **Description** |
1812
+ | --- | --- |
1813
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.toString">toString</a></code> | Returns a string representation of this construct. |
1814
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.with">with</a></code> | Applies one or more mixins to this construct. |
1815
+
1816
+ ---
1817
+
1818
+ ##### `toString` <a name="toString" id="cdk-nextjs.NextjsImageFunction.toString"></a>
1819
+
1820
+ ```typescript
1821
+ public toString(): string
1822
+ ```
1823
+
1824
+ Returns a string representation of this construct.
1825
+
1826
+ ##### `with` <a name="with" id="cdk-nextjs.NextjsImageFunction.with"></a>
1827
+
1828
+ ```typescript
1829
+ public with(mixins: ...IMixin[]): IConstruct
1830
+ ```
1831
+
1832
+ Applies one or more mixins to this construct.
1833
+
1834
+ Mixins are applied in order. The list of constructs is captured at the
1835
+ start of the call, so constructs added by a mixin will not be visited.
1836
+ Use multiple `with()` calls if subsequent mixins should apply to added
1837
+ constructs.
1838
+
1839
+ ###### `mixins`<sup>Required</sup> <a name="mixins" id="cdk-nextjs.NextjsImageFunction.with.parameter.mixins"></a>
1840
+
1841
+ - *Type:* ...constructs.IMixin[]
1842
+
1843
+ The mixins to apply.
1844
+
1845
+ ---
1846
+
1847
+ #### Static Functions <a name="Static Functions" id="Static Functions"></a>
1848
+
1849
+ | **Name** | **Description** |
1850
+ | --- | --- |
1851
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |
1852
+
1853
+ ---
1854
+
1855
+ ##### `isConstruct` <a name="isConstruct" id="cdk-nextjs.NextjsImageFunction.isConstruct"></a>
1856
+
1857
+ ```typescript
1858
+ import { NextjsImageFunction } from 'cdk-nextjs'
1859
+
1860
+ NextjsImageFunction.isConstruct(x: any)
1861
+ ```
1862
+
1863
+ Checks if `x` is a construct.
1864
+
1865
+ Use this method instead of `instanceof` to properly detect `Construct`
1866
+ instances, even when the construct library is symlinked.
1867
+
1868
+ Explanation: in JavaScript, multiple copies of the `constructs` library on
1869
+ disk are seen as independent, completely different libraries. As a
1870
+ consequence, the class `Construct` in each copy of the `constructs` library
1871
+ is seen as a different class, and an instance of one class will not test as
1872
+ `instanceof` the other class. `npm install` will not create installations
1873
+ like this, but users may manually symlink construct libraries together or
1874
+ use a monorepo tool: in those cases, multiple copies of the `constructs`
1875
+ library can be accidentally installed, and `instanceof` will behave
1876
+ unpredictably. It is safest to avoid using `instanceof`, and using
1877
+ this type-testing method instead.
1878
+
1879
+ ###### `x`<sup>Required</sup> <a name="x" id="cdk-nextjs.NextjsImageFunction.isConstruct.parameter.x"></a>
1880
+
1881
+ - *Type:* any
1882
+
1883
+ Any object.
1884
+
1885
+ ---
1886
+
1887
+ #### Properties <a name="Properties" id="Properties"></a>
1888
+
1889
+ | **Name** | **Type** | **Description** |
1890
+ | --- | --- | --- |
1891
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
1892
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.property.function">function</a></code> | <code>aws-cdk-lib.aws_lambda.Function</code> | *No description.* |
1893
+ | <code><a href="#cdk-nextjs.NextjsImageFunction.property.functionUrl">functionUrl</a></code> | <code>aws-cdk-lib.aws_lambda.FunctionUrl</code> | *No description.* |
1894
+
1895
+ ---
1896
+
1897
+ ##### `node`<sup>Required</sup> <a name="node" id="cdk-nextjs.NextjsImageFunction.property.node"></a>
1898
+
1899
+ ```typescript
1900
+ public readonly node: Node;
1901
+ ```
1902
+
1903
+ - *Type:* constructs.Node
1904
+
1905
+ The tree node.
1906
+
1907
+ ---
1908
+
1909
+ ##### `function`<sup>Required</sup> <a name="function" id="cdk-nextjs.NextjsImageFunction.property.function"></a>
1910
+
1911
+ ```typescript
1912
+ public readonly function: Function;
1913
+ ```
1914
+
1915
+ - *Type:* aws-cdk-lib.aws_lambda.Function
1916
+
1917
+ ---
1918
+
1919
+ ##### `functionUrl`<sup>Optional</sup> <a name="functionUrl" id="cdk-nextjs.NextjsImageFunction.property.functionUrl"></a>
1920
+
1921
+ ```typescript
1922
+ public readonly functionUrl: FunctionUrl;
1923
+ ```
1924
+
1925
+ - *Type:* aws-cdk-lib.aws_lambda.FunctionUrl
1926
+
1927
+ ---
1928
+
1704
1929
 
1705
1930
  ### NextjsPostDeploy <a name="NextjsPostDeploy" id="cdk-nextjs.NextjsPostDeploy"></a>
1706
1931
 
@@ -2198,6 +2423,7 @@ Any object.
2198
2423
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctions.property.nextjsApi">nextjsApi</a></code> | <code><a href="#cdk-nextjs.NextjsApi">NextjsApi</a></code> | *No description.* |
2199
2424
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctions.property.nextjsFunctions">nextjsFunctions</a></code> | <code><a href="#cdk-nextjs.NextjsFunctions">NextjsFunctions</a></code> | *No description.* |
2200
2425
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctions.property.nextjsPostDeploy">nextjsPostDeploy</a></code> | <code><a href="#cdk-nextjs.NextjsPostDeploy">NextjsPostDeploy</a></code> | *No description.* |
2426
+ | <code><a href="#cdk-nextjs.NextjsRegionalFunctions.property.nextjsImageFunction">nextjsImageFunction</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunction">NextjsImageFunction</a></code> | Only created when the (experimental, unsupported) dedicated image optimization Lambda is enabled. |
2201
2427
 
2202
2428
  ---
2203
2429
 
@@ -2283,6 +2509,21 @@ public readonly nextjsPostDeploy: NextjsPostDeploy;
2283
2509
 
2284
2510
  ---
2285
2511
 
2512
+ ##### `nextjsImageFunction`<sup>Optional</sup> <a name="nextjsImageFunction" id="cdk-nextjs.NextjsRegionalFunctions.property.nextjsImageFunction"></a>
2513
+
2514
+ ```typescript
2515
+ public readonly nextjsImageFunction: NextjsImageFunction;
2516
+ ```
2517
+
2518
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunction">NextjsImageFunction</a>
2519
+
2520
+ Only created when the (experimental, unsupported) dedicated image optimization Lambda is enabled.
2521
+
2522
+ `_next/image` is otherwise served by
2523
+ {@link nextjsFunctions}.
2524
+
2525
+ ---
2526
+
2286
2527
 
2287
2528
  ### NextjsStaticAssets <a name="NextjsStaticAssets" id="cdk-nextjs.NextjsStaticAssets"></a>
2288
2529
 
@@ -2405,6 +2646,7 @@ Any object.
2405
2646
  | **Name** | **Type** | **Description** |
2406
2647
  | --- | --- | --- |
2407
2648
  | <code><a href="#cdk-nextjs.NextjsStaticAssets.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
2649
+ | <code><a href="#cdk-nextjs.NextjsStaticAssets.property.keyPrefix">keyPrefix</a></code> | <code>string</code> | S3 key prefix the assets are actually uploaded under, normalized to a bare path segment (empty when they live at the bucket root). |
2408
2650
  | <code><a href="#cdk-nextjs.NextjsStaticAssets.property.bucket">bucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | *No description.* |
2409
2651
  | <code><a href="#cdk-nextjs.NextjsStaticAssets.property.deployment">deployment</a></code> | <code>aws-cdk-lib.aws_s3_deployment.BucketDeployment</code> | *No description.* |
2410
2652
 
@@ -2422,6 +2664,23 @@ The tree node.
2422
2664
 
2423
2665
  ---
2424
2666
 
2667
+ ##### `keyPrefix`<sup>Required</sup> <a name="keyPrefix" id="cdk-nextjs.NextjsStaticAssets.property.keyPrefix"></a>
2668
+
2669
+ ```typescript
2670
+ public readonly keyPrefix: string;
2671
+ ```
2672
+
2673
+ - *Type:* string
2674
+
2675
+ S3 key prefix the assets are actually uploaded under, normalized to a bare path segment (empty when they live at the bucket root).
2676
+
2677
+ Consumers that read assets back out of the bucket (the image optimization
2678
+ Lambda, `NextjsApi`'s S3 integrations) must use this rather than the
2679
+ `basePath` prop, since `overrides.bucketDeploymentProps` can replace the
2680
+ prefix outright.
2681
+
2682
+ ---
2683
+
2425
2684
  ##### `bucket`<sup>Required</sup> <a name="bucket" id="cdk-nextjs.NextjsStaticAssets.property.bucket"></a>
2426
2685
 
2427
2686
  ```typescript
@@ -2460,6 +2719,7 @@ const nextjsApiOverrides: NextjsApiOverrides = { ... }
2460
2719
  | **Name** | **Type** | **Description** |
2461
2720
  | --- | --- | --- |
2462
2721
  | <code><a href="#cdk-nextjs.NextjsApiOverrides.property.dynamicIntegrationProps">dynamicIntegrationProps</a></code> | <code>aws-cdk-lib.aws_apigateway.LambdaIntegrationOptions</code> | *No description.* |
2722
+ | <code><a href="#cdk-nextjs.NextjsApiOverrides.property.imageIntegrationProps">imageIntegrationProps</a></code> | <code>aws-cdk-lib.aws_apigateway.LambdaIntegrationOptions</code> | *No description.* |
2463
2723
  | <code><a href="#cdk-nextjs.NextjsApiOverrides.property.restApiProps">restApiProps</a></code> | <code>aws-cdk-lib.aws_apigateway.RestApiProps</code> | *No description.* |
2464
2724
  | <code><a href="#cdk-nextjs.NextjsApiOverrides.property.s3MethodOptions">s3MethodOptions</a></code> | <code>aws-cdk-lib.aws_apigateway.MethodOptions</code> | *No description.* |
2465
2725
  | <code><a href="#cdk-nextjs.NextjsApiOverrides.property.staticIntegrationProps">staticIntegrationProps</a></code> | <code>aws-cdk-lib.aws_apigateway.AwsIntegrationProps</code> | *No description.* |
@@ -2476,6 +2736,16 @@ public readonly dynamicIntegrationProps: LambdaIntegrationOptions;
2476
2736
 
2477
2737
  ---
2478
2738
 
2739
+ ##### `imageIntegrationProps`<sup>Optional</sup> <a name="imageIntegrationProps" id="cdk-nextjs.NextjsApiOverrides.property.imageIntegrationProps"></a>
2740
+
2741
+ ```typescript
2742
+ public readonly imageIntegrationProps: LambdaIntegrationOptions;
2743
+ ```
2744
+
2745
+ - *Type:* aws-cdk-lib.aws_apigateway.LambdaIntegrationOptions
2746
+
2747
+ ---
2748
+
2479
2749
  ##### `restApiProps`<sup>Optional</sup> <a name="restApiProps" id="cdk-nextjs.NextjsApiOverrides.property.restApiProps"></a>
2480
2750
 
2481
2751
  ```typescript
@@ -2523,8 +2793,10 @@ const nextjsApiProps: NextjsApiProps = { ... }
2523
2793
  | <code><a href="#cdk-nextjs.NextjsApiProps.property.publicDirEntries">publicDirEntries</a></code> | <code><a href="#cdk-nextjs.PublicDirEntry">PublicDirEntry</a>[]</code> | Path to directory of Next.js app's public directory. Used to add resources to API Gateway REST API for public directory to go directly to S3. |
2524
2794
  | <code><a href="#cdk-nextjs.NextjsApiProps.property.staticAssetsBucket">staticAssetsBucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | The S3 bucket containing static assets. |
2525
2795
  | <code><a href="#cdk-nextjs.NextjsApiProps.property.basePath">basePath</a></code> | <code>string</code> | Optional base path for the application. |
2796
+ | <code><a href="#cdk-nextjs.NextjsApiProps.property.imageFunction">imageFunction</a></code> | <code>aws-cdk-lib.aws_lambda.IFunction</code> | Dedicated image optimization Lambda for the `_next/image` route. |
2526
2797
  | <code><a href="#cdk-nextjs.NextjsApiProps.property.overrides">overrides</a></code> | <code><a href="#cdk-nextjs.NextjsApiOverrides">NextjsApiOverrides</a></code> | Override props for every construct. |
2527
2798
  | <code><a href="#cdk-nextjs.NextjsApiProps.property.serverFunction">serverFunction</a></code> | <code>aws-cdk-lib.aws_lambda.IFunction</code> | Required if `NextjsRegionalFunctions`. |
2799
+ | <code><a href="#cdk-nextjs.NextjsApiProps.property.staticAssetsKeyPrefix">staticAssetsKeyPrefix</a></code> | <code>string</code> | S3 key prefix the static assets were uploaded under, i.e. `NextjsStaticAssets.keyPrefix`, which namespaces a shared bucket. |
2528
2800
  | <code><a href="#cdk-nextjs.NextjsApiProps.property.vpc">vpc</a></code> | <code>aws-cdk-lib.aws_ec2.IVpc</code> | [Future] Required if `NextjsRegionalContainers`. |
2529
2801
 
2530
2802
  ---
@@ -2565,6 +2837,29 @@ Optional base path for the application.
2565
2837
 
2566
2838
  ---
2567
2839
 
2840
+ ##### `imageFunction`<sup>Optional</sup> <a name="imageFunction" id="cdk-nextjs.NextjsApiProps.property.imageFunction"></a>
2841
+
2842
+ ```typescript
2843
+ public readonly imageFunction: IFunction;
2844
+ ```
2845
+
2846
+ - *Type:* aws-cdk-lib.aws_lambda.IFunction
2847
+
2848
+ Dedicated image optimization Lambda for the `_next/image` route.
2849
+
2850
+ When
2851
+ omitted, no `_next/image` resource is created and those requests fall
2852
+ through to `serverFunction` via the `{proxy+}` catch-all.
2853
+
2854
+ When provided, it is assumed to support Lambda response streaming (as the
2855
+ dedicated image Lambda this package builds does) and is invoked with
2856
+ `ResponseTransferMode.STREAM` accordingly. If you supply a custom
2857
+ `imageFunction` that doesn't support streaming, override
2858
+ `responseTransferMode` to `BUFFERED` via `overrides.imageIntegrationProps`,
2859
+ otherwise API Gateway returns a 502.
2860
+
2861
+ ---
2862
+
2568
2863
  ##### `overrides`<sup>Optional</sup> <a name="overrides" id="cdk-nextjs.NextjsApiProps.property.overrides"></a>
2569
2864
 
2570
2865
  ```typescript
@@ -2591,6 +2886,24 @@ The Lambda function for server-side rendering
2591
2886
 
2592
2887
  ---
2593
2888
 
2889
+ ##### `staticAssetsKeyPrefix`<sup>Optional</sup> <a name="staticAssetsKeyPrefix" id="cdk-nextjs.NextjsApiProps.property.staticAssetsKeyPrefix"></a>
2890
+
2891
+ ```typescript
2892
+ public readonly staticAssetsKeyPrefix: string;
2893
+ ```
2894
+
2895
+ - *Type:* string
2896
+
2897
+ S3 key prefix the static assets were uploaded under, i.e. `NextjsStaticAssets.keyPrefix`, which namespaces a shared bucket.
2898
+
2899
+ Independent of `basePath` above: that one is the URL prefix the REST API
2900
+ serves the app at (commonly the API Gateway stage), while this one is where
2901
+ the objects live in the bucket. `_next/static` and public directory
2902
+ requests are mapped to S3 keys directly, so they 404 unless this prefix is
2903
+ applied.
2904
+
2905
+ ---
2906
+
2594
2907
  ##### `vpc`<sup>Optional</sup> <a name="vpc" id="cdk-nextjs.NextjsApiProps.property.vpc"></a>
2595
2908
 
2596
2909
  ```typescript
@@ -2739,6 +3052,29 @@ public readonly basePath: string;
2739
3052
 
2740
3053
  Prefix to the URI path the app will be served at.
2741
3054
 
3055
+ Also namespaces the
3056
+ static assets in S3, so it doubles as a way to host multiple apps or
3057
+ branches out of one bucket.
3058
+
3059
+ How this relates to the `basePath` in your app's `next.config.js` depends
3060
+ on the construct, and synth fails on a combination that can't serve the
3061
+ app:
3062
+
3063
+ - `NextjsGlobalFunctions`/`NextjsGlobalContainers`: leave this unset and it
3064
+ follows your app's `basePath`, which is what you want — CloudFront serves
3065
+ static assets from S3 using the request path as the object key, so the two
3066
+ have to be identical and a mismatch 404s all of them. Setting a different
3067
+ value throws.
3068
+ - `NextjsRegionalFunctions`: if you set this, the app's `basePath` must end
3069
+ with it — either equal to it, or prefixed by the stage or base path
3070
+ mapping API Gateway strips before matching resources (`basePath:
3071
+ "/prod/base"` with this set to `"/base"`). Leaving it unset while the app
3072
+ sets one is correct and common — an app served at the default `prod` stage
3073
+ sets `basePath: "/prod"` and leaves this alone.
3074
+ - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
3075
+ every path to the container, which serves its own static assets, so this
3076
+ is unconstrained.
3077
+
2742
3078
  ---
2743
3079
 
2744
3080
  *Example*
@@ -2974,6 +3310,29 @@ public readonly basePath: string;
2974
3310
 
2975
3311
  Prefix to the URI path the app will be served at.
2976
3312
 
3313
+ Also namespaces the
3314
+ static assets in S3, so it doubles as a way to host multiple apps or
3315
+ branches out of one bucket.
3316
+
3317
+ How this relates to the `basePath` in your app's `next.config.js` depends
3318
+ on the construct, and synth fails on a combination that can't serve the
3319
+ app:
3320
+
3321
+ - `NextjsGlobalFunctions`/`NextjsGlobalContainers`: leave this unset and it
3322
+ follows your app's `basePath`, which is what you want — CloudFront serves
3323
+ static assets from S3 using the request path as the object key, so the two
3324
+ have to be identical and a mismatch 404s all of them. Setting a different
3325
+ value throws.
3326
+ - `NextjsRegionalFunctions`: if you set this, the app's `basePath` must end
3327
+ with it — either equal to it, or prefixed by the stage or base path
3328
+ mapping API Gateway strips before matching resources (`basePath:
3329
+ "/prod/base"` with this set to `"/base"`). Leaving it unset while the app
3330
+ sets one is correct and common — an app served at the default `prod` stage
3331
+ sets `basePath: "/prod"` and leaves this alone.
3332
+ - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
3333
+ every path to the container, which serves its own static assets, so this
3334
+ is unconstrained.
3335
+
2977
3336
  ---
2978
3337
 
2979
3338
  *Example*
@@ -3638,6 +3997,7 @@ const nextjsDistributionOverrides: NextjsDistributionOverrides = { ... }
3638
3997
  | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.dynamicVpcOriginWithEndpointProps">dynamicVpcOriginWithEndpointProps</a></code> | <code>aws-cdk-lib.aws_cloudfront_origins.VpcOriginWithEndpointProps</code> | *No description.* |
3639
3998
  | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.imageBehaviorOptions">imageBehaviorOptions</a></code> | <code>aws-cdk-lib.aws_cloudfront.AddBehaviorOptions</code> | *No description.* |
3640
3999
  | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.imageCachePolicyProps">imageCachePolicyProps</a></code> | <code>aws-cdk-lib.aws_cloudfront.CachePolicyProps</code> | *No description.* |
4000
+ | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.imageFunctionUrlOriginWithOACProps">imageFunctionUrlOriginWithOACProps</a></code> | <code>aws-cdk-lib.aws_cloudfront_origins.FunctionUrlOriginWithOACProps</code> | *No description.* |
3641
4001
  | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.imageResponseHeadersPolicyProps">imageResponseHeadersPolicyProps</a></code> | <code>aws-cdk-lib.aws_cloudfront.ResponseHeadersPolicyProps</code> | *No description.* |
3642
4002
  | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.s3BucketOriginProps">s3BucketOriginProps</a></code> | <code><a href="#cdk-nextjs.OptionalS3OriginBucketWithOACProps">OptionalS3OriginBucketWithOACProps</a></code> | *No description.* |
3643
4003
  | <code><a href="#cdk-nextjs.NextjsDistributionOverrides.property.staticBehaviorOptions">staticBehaviorOptions</a></code> | <code>aws-cdk-lib.aws_cloudfront.AddBehaviorOptions</code> | *No description.* |
@@ -3725,6 +4085,16 @@ public readonly imageCachePolicyProps: CachePolicyProps;
3725
4085
 
3726
4086
  ---
3727
4087
 
4088
+ ##### `imageFunctionUrlOriginWithOACProps`<sup>Optional</sup> <a name="imageFunctionUrlOriginWithOACProps" id="cdk-nextjs.NextjsDistributionOverrides.property.imageFunctionUrlOriginWithOACProps"></a>
4089
+
4090
+ ```typescript
4091
+ public readonly imageFunctionUrlOriginWithOACProps: FunctionUrlOriginWithOACProps;
4092
+ ```
4093
+
4094
+ - *Type:* aws-cdk-lib.aws_cloudfront_origins.FunctionUrlOriginWithOACProps
4095
+
4096
+ ---
4097
+
3728
4098
  ##### `imageResponseHeadersPolicyProps`<sup>Optional</sup> <a name="imageResponseHeadersPolicyProps" id="cdk-nextjs.NextjsDistributionOverrides.property.imageResponseHeadersPolicyProps"></a>
3729
4099
 
3730
4100
  ```typescript
@@ -3782,10 +4152,11 @@ const nextjsDistributionProps: NextjsDistributionProps = { ... }
3782
4152
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.assetsBucket">assetsBucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | Bucket containing static assets. |
3783
4153
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.nextjsType">nextjsType</a></code> | <code><a href="#cdk-nextjs.NextjsType">NextjsType</a></code> | *No description.* |
3784
4154
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.publicDirEntries">publicDirEntries</a></code> | <code><a href="#cdk-nextjs.PublicDirEntry">PublicDirEntry</a>[]</code> | Entries (files/directories) within Next.js app's public directory. Used to add static behaviors to distribution. |
3785
- | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.basePath">basePath</a></code> | <code>string</code> | *No description.* |
4155
+ | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.basePath">basePath</a></code> | <code>string</code> | URI path prefix the app is served at. |
3786
4156
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.certificate">certificate</a></code> | <code>aws-cdk-lib.aws_certificatemanager.ICertificate</code> | Optional but only applicable for `NextjsType.GLOBAL_CONTAINERS`. |
3787
4157
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.distribution">distribution</a></code> | <code>aws-cdk-lib.aws_cloudfront.Distribution</code> | *No description.* |
3788
4158
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.functionUrl">functionUrl</a></code> | <code>aws-cdk-lib.aws_lambda.IFunctionUrl</code> | Required if `NextjsType.GLOBAL_FUNCTIONS`. |
4159
+ | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.imageFunctionUrl">imageFunctionUrl</a></code> | <code>aws-cdk-lib.aws_lambda.IFunctionUrl</code> | Function URL of the dedicated image optimization Lambda. |
3789
4160
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.loadBalancer">loadBalancer</a></code> | <code>aws-cdk-lib.aws_elasticloadbalancingv2.IApplicationLoadBalancer</code> | Required if `NextjsType.GLOBAL_CONTAINERS` or `NextjsType.REGIONAL_CONTAINERS`. |
3790
4161
  | <code><a href="#cdk-nextjs.NextjsDistributionProps.property.overrides">overrides</a></code> | <code><a href="#cdk-nextjs.NextjsDistributionOverrides">NextjsDistributionOverrides</a></code> | Override props for every construct. |
3791
4162
 
@@ -3835,6 +4206,11 @@ public readonly basePath: string;
3835
4206
 
3836
4207
  - *Type:* string
3837
4208
 
4209
+ URI path prefix the app is served at.
4210
+
4211
+ Surrounding slashes are normalized
4212
+ away, so "/base", "base" and "/base/" all produce the same cache behaviors.
4213
+
3838
4214
  ---
3839
4215
 
3840
4216
  ##### `certificate`<sup>Optional</sup> <a name="certificate" id="cdk-nextjs.NextjsDistributionProps.property.certificate"></a>
@@ -3871,6 +4247,24 @@ Required if `NextjsType.GLOBAL_FUNCTIONS`.
3871
4247
 
3872
4248
  ---
3873
4249
 
4250
+ ##### `imageFunctionUrl`<sup>Optional</sup> <a name="imageFunctionUrl" id="cdk-nextjs.NextjsDistributionProps.property.imageFunctionUrl"></a>
4251
+
4252
+ ```typescript
4253
+ public readonly imageFunctionUrl: IFunctionUrl;
4254
+ ```
4255
+
4256
+ - *Type:* aws-cdk-lib.aws_lambda.IFunctionUrl
4257
+
4258
+ Function URL of the dedicated image optimization Lambda.
4259
+
4260
+ Only applicable
4261
+ to `NextjsType.GLOBAL_FUNCTIONS`, and only when the dedicated image
4262
+ function is enabled. When omitted, the `_next/image*` behavior points at
4263
+ the dynamic origin, which serves image optimization from the Next.js
4264
+ server itself.
4265
+
4266
+ ---
4267
+
3874
4268
  ##### `loadBalancer`<sup>Optional</sup> <a name="loadBalancer" id="cdk-nextjs.NextjsDistributionProps.property.loadBalancer"></a>
3875
4269
 
3876
4270
  ```typescript
@@ -3895,6 +4289,84 @@ Override props for every construct.
3895
4289
 
3896
4290
  ---
3897
4291
 
4292
+ ### NextjsFunctionsConstructOverrides <a name="NextjsFunctionsConstructOverrides" id="cdk-nextjs.NextjsFunctionsConstructOverrides"></a>
4293
+
4294
+ Adds the overrides that only apply to the two Functions `NextjsType`s.
4295
+
4296
+ The
4297
+ Containers types serve `_next/image` from the standalone server itself and
4298
+ have no Lambda functions to configure, so they would silently ignore these.
4299
+
4300
+ #### Initializer <a name="Initializer" id="cdk-nextjs.NextjsFunctionsConstructOverrides.Initializer"></a>
4301
+
4302
+ ```typescript
4303
+ import { NextjsFunctionsConstructOverrides } from 'cdk-nextjs'
4304
+
4305
+ const nextjsFunctionsConstructOverrides: NextjsFunctionsConstructOverrides = { ... }
4306
+ ```
4307
+
4308
+ #### Properties <a name="Properties" id="Properties"></a>
4309
+
4310
+ | **Name** | **Type** | **Description** |
4311
+ | --- | --- | --- |
4312
+ | <code><a href="#cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsBuildProps">nextjsBuildProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsBuildProps">OptionalNextjsBuildProps</a></code> | *No description.* |
4313
+ | <code><a href="#cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsCacheProps">nextjsCacheProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsCacheProps">OptionalNextjsCacheProps</a></code> | *No description.* |
4314
+ | <code><a href="#cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsStaticAssetsProps">nextjsStaticAssetsProps</a></code> | <code><a href="#cdk-nextjs.NextjsStaticAssetsProps">NextjsStaticAssetsProps</a></code> | *No description.* |
4315
+ | <code><a href="#cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsFunctionsProps">nextjsFunctionsProps</a></code> | <code><a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a></code> | *No description.* |
4316
+ | <code><a href="#cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsImageFunctionProps">nextjsImageFunctionProps</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a></code> | *No description.* |
4317
+
4318
+ ---
4319
+
4320
+ ##### `nextjsBuildProps`<sup>Optional</sup> <a name="nextjsBuildProps" id="cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsBuildProps"></a>
4321
+
4322
+ ```typescript
4323
+ public readonly nextjsBuildProps: OptionalNextjsBuildProps;
4324
+ ```
4325
+
4326
+ - *Type:* <a href="#cdk-nextjs.OptionalNextjsBuildProps">OptionalNextjsBuildProps</a>
4327
+
4328
+ ---
4329
+
4330
+ ##### `nextjsCacheProps`<sup>Optional</sup> <a name="nextjsCacheProps" id="cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsCacheProps"></a>
4331
+
4332
+ ```typescript
4333
+ public readonly nextjsCacheProps: OptionalNextjsCacheProps;
4334
+ ```
4335
+
4336
+ - *Type:* <a href="#cdk-nextjs.OptionalNextjsCacheProps">OptionalNextjsCacheProps</a>
4337
+
4338
+ ---
4339
+
4340
+ ##### `nextjsStaticAssetsProps`<sup>Optional</sup> <a name="nextjsStaticAssetsProps" id="cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsStaticAssetsProps"></a>
4341
+
4342
+ ```typescript
4343
+ public readonly nextjsStaticAssetsProps: NextjsStaticAssetsProps;
4344
+ ```
4345
+
4346
+ - *Type:* <a href="#cdk-nextjs.NextjsStaticAssetsProps">NextjsStaticAssetsProps</a>
4347
+
4348
+ ---
4349
+
4350
+ ##### `nextjsFunctionsProps`<sup>Optional</sup> <a name="nextjsFunctionsProps" id="cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsFunctionsProps"></a>
4351
+
4352
+ ```typescript
4353
+ public readonly nextjsFunctionsProps: NextjsFunctionsProps;
4354
+ ```
4355
+
4356
+ - *Type:* <a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a>
4357
+
4358
+ ---
4359
+
4360
+ ##### `nextjsImageFunctionProps`<sup>Optional</sup> <a name="nextjsImageFunctionProps" id="cdk-nextjs.NextjsFunctionsConstructOverrides.property.nextjsImageFunctionProps"></a>
4361
+
4362
+ ```typescript
4363
+ public readonly nextjsImageFunctionProps: NextjsImageFunctionProps;
4364
+ ```
4365
+
4366
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a>
4367
+
4368
+ ---
4369
+
3898
4370
  ### NextjsFunctionsOverrides <a name="NextjsFunctionsOverrides" id="cdk-nextjs.NextjsFunctionsOverrides"></a>
3899
4371
 
3900
4372
  #### Initializer <a name="Initializer" id="cdk-nextjs.NextjsFunctionsOverrides.Initializer"></a>
@@ -4315,6 +4787,29 @@ public readonly basePath: string;
4315
4787
 
4316
4788
  Prefix to the URI path the app will be served at.
4317
4789
 
4790
+ Also namespaces the
4791
+ static assets in S3, so it doubles as a way to host multiple apps or
4792
+ branches out of one bucket.
4793
+
4794
+ How this relates to the `basePath` in your app's `next.config.js` depends
4795
+ on the construct, and synth fails on a combination that can't serve the
4796
+ app:
4797
+
4798
+ - `NextjsGlobalFunctions`/`NextjsGlobalContainers`: leave this unset and it
4799
+ follows your app's `basePath`, which is what you want — CloudFront serves
4800
+ static assets from S3 using the request path as the object key, so the two
4801
+ have to be identical and a mismatch 404s all of them. Setting a different
4802
+ value throws.
4803
+ - `NextjsRegionalFunctions`: if you set this, the app's `basePath` must end
4804
+ with it — either equal to it, or prefixed by the stage or base path
4805
+ mapping API Gateway strips before matching resources (`basePath:
4806
+ "/prod/base"` with this set to `"/base"`). Leaving it unset while the app
4807
+ sets one is correct and common — an app served at the default `prod` stage
4808
+ sets `basePath: "/prod"` and leaves this alone.
4809
+ - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
4810
+ every path to the container, which serves its own static assets, so this
4811
+ is unconstrained.
4812
+
4318
4813
  ---
4319
4814
 
4320
4815
  *Example*
@@ -4496,8 +4991,9 @@ const nextjsGlobalFunctionsConstructOverrides: NextjsGlobalFunctionsConstructOve
4496
4991
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsBuildProps">nextjsBuildProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsBuildProps">OptionalNextjsBuildProps</a></code> | *No description.* |
4497
4992
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsCacheProps">nextjsCacheProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsCacheProps">OptionalNextjsCacheProps</a></code> | *No description.* |
4498
4993
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsStaticAssetsProps">nextjsStaticAssetsProps</a></code> | <code><a href="#cdk-nextjs.NextjsStaticAssetsProps">NextjsStaticAssetsProps</a></code> | *No description.* |
4499
- | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsDistributionProps">nextjsDistributionProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps">OptionalNextjsDistributionProps</a></code> | *No description.* |
4500
4994
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsFunctionsProps">nextjsFunctionsProps</a></code> | <code><a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a></code> | *No description.* |
4995
+ | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsImageFunctionProps">nextjsImageFunctionProps</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a></code> | *No description.* |
4996
+ | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsDistributionProps">nextjsDistributionProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps">OptionalNextjsDistributionProps</a></code> | *No description.* |
4501
4997
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsPostDeployProps">nextjsPostDeployProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsPostDeployProps">OptionalNextjsPostDeployProps</a></code> | *No description.* |
4502
4998
 
4503
4999
  ---
@@ -4532,23 +5028,33 @@ public readonly nextjsStaticAssetsProps: NextjsStaticAssetsProps;
4532
5028
 
4533
5029
  ---
4534
5030
 
4535
- ##### `nextjsDistributionProps`<sup>Optional</sup> <a name="nextjsDistributionProps" id="cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsDistributionProps"></a>
5031
+ ##### `nextjsFunctionsProps`<sup>Optional</sup> <a name="nextjsFunctionsProps" id="cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsFunctionsProps"></a>
4536
5032
 
4537
5033
  ```typescript
4538
- public readonly nextjsDistributionProps: OptionalNextjsDistributionProps;
5034
+ public readonly nextjsFunctionsProps: NextjsFunctionsProps;
4539
5035
  ```
4540
5036
 
4541
- - *Type:* <a href="#cdk-nextjs.OptionalNextjsDistributionProps">OptionalNextjsDistributionProps</a>
5037
+ - *Type:* <a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a>
4542
5038
 
4543
5039
  ---
4544
5040
 
4545
- ##### `nextjsFunctionsProps`<sup>Optional</sup> <a name="nextjsFunctionsProps" id="cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsFunctionsProps"></a>
5041
+ ##### `nextjsImageFunctionProps`<sup>Optional</sup> <a name="nextjsImageFunctionProps" id="cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsImageFunctionProps"></a>
4546
5042
 
4547
5043
  ```typescript
4548
- public readonly nextjsFunctionsProps: NextjsFunctionsProps;
5044
+ public readonly nextjsImageFunctionProps: NextjsImageFunctionProps;
4549
5045
  ```
4550
5046
 
4551
- - *Type:* <a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a>
5047
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a>
5048
+
5049
+ ---
5050
+
5051
+ ##### `nextjsDistributionProps`<sup>Optional</sup> <a name="nextjsDistributionProps" id="cdk-nextjs.NextjsGlobalFunctionsConstructOverrides.property.nextjsDistributionProps"></a>
5052
+
5053
+ ```typescript
5054
+ public readonly nextjsDistributionProps: OptionalNextjsDistributionProps;
5055
+ ```
5056
+
5057
+ - *Type:* <a href="#cdk-nextjs.OptionalNextjsDistributionProps">OptionalNextjsDistributionProps</a>
4552
5058
 
4553
5059
  ---
4554
5060
 
@@ -4587,6 +5093,7 @@ const nextjsGlobalFunctionsOverrides: NextjsGlobalFunctionsOverrides = { ... }
4587
5093
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsDistribution">nextjsDistribution</a></code> | <code><a href="#cdk-nextjs.NextjsDistributionOverrides">NextjsDistributionOverrides</a></code> | *No description.* |
4588
5094
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsFunctions">nextjsFunctions</a></code> | <code><a href="#cdk-nextjs.NextjsFunctionsOverrides">NextjsFunctionsOverrides</a></code> | *No description.* |
4589
5095
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsGlobalFunctions">nextjsGlobalFunctions</a></code> | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsConstructOverrides">NextjsGlobalFunctionsConstructOverrides</a></code> | *No description.* |
5096
+ | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsImageFunction">nextjsImageFunction</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionOverrides">NextjsImageFunctionOverrides</a></code> | *No description.* |
4590
5097
  | <code><a href="#cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsPostDeploy">nextjsPostDeploy</a></code> | <code><a href="#cdk-nextjs.NextjsPostDeployOverrides">NextjsPostDeployOverrides</a></code> | *No description.* |
4591
5098
 
4592
5099
  ---
@@ -4641,6 +5148,16 @@ public readonly nextjsGlobalFunctions: NextjsGlobalFunctionsConstructOverrides;
4641
5148
 
4642
5149
  ---
4643
5150
 
5151
+ ##### `nextjsImageFunction`<sup>Optional</sup> <a name="nextjsImageFunction" id="cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsImageFunction"></a>
5152
+
5153
+ ```typescript
5154
+ public readonly nextjsImageFunction: NextjsImageFunctionOverrides;
5155
+ ```
5156
+
5157
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionOverrides">NextjsImageFunctionOverrides</a>
5158
+
5159
+ ---
5160
+
4644
5161
  ##### `nextjsPostDeploy`<sup>Optional</sup> <a name="nextjsPostDeploy" id="cdk-nextjs.NextjsGlobalFunctionsOverrides.property.nextjsPostDeploy"></a>
4645
5162
 
4646
5163
  ```typescript
@@ -4732,6 +5249,29 @@ public readonly basePath: string;
4732
5249
 
4733
5250
  Prefix to the URI path the app will be served at.
4734
5251
 
5252
+ Also namespaces the
5253
+ static assets in S3, so it doubles as a way to host multiple apps or
5254
+ branches out of one bucket.
5255
+
5256
+ How this relates to the `basePath` in your app's `next.config.js` depends
5257
+ on the construct, and synth fails on a combination that can't serve the
5258
+ app:
5259
+
5260
+ - `NextjsGlobalFunctions`/`NextjsGlobalContainers`: leave this unset and it
5261
+ follows your app's `basePath`, which is what you want — CloudFront serves
5262
+ static assets from S3 using the request path as the object key, so the two
5263
+ have to be identical and a mismatch 404s all of them. Setting a different
5264
+ value throws.
5265
+ - `NextjsRegionalFunctions`: if you set this, the app's `basePath` must end
5266
+ with it — either equal to it, or prefixed by the stage or base path
5267
+ mapping API Gateway strips before matching resources (`basePath:
5268
+ "/prod/base"` with this set to `"/base"`). Leaving it unset while the app
5269
+ sets one is correct and common — an app served at the default `prod` stage
5270
+ sets `basePath: "/prod"` and leaves this alone.
5271
+ - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
5272
+ every path to the container, which serves its own static assets, so this
5273
+ is unconstrained.
5274
+
4735
5275
  ---
4736
5276
 
4737
5277
  *Example*
@@ -4864,6 +5404,143 @@ Override props of any construct.
4864
5404
 
4865
5405
  ---
4866
5406
 
5407
+ ### NextjsImageFunctionOverrides <a name="NextjsImageFunctionOverrides" id="cdk-nextjs.NextjsImageFunctionOverrides"></a>
5408
+
5409
+ #### Initializer <a name="Initializer" id="cdk-nextjs.NextjsImageFunctionOverrides.Initializer"></a>
5410
+
5411
+ ```typescript
5412
+ import { NextjsImageFunctionOverrides } from 'cdk-nextjs'
5413
+
5414
+ const nextjsImageFunctionOverrides: NextjsImageFunctionOverrides = { ... }
5415
+ ```
5416
+
5417
+ #### Properties <a name="Properties" id="Properties"></a>
5418
+
5419
+ | **Name** | **Type** | **Description** |
5420
+ | --- | --- | --- |
5421
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionOverrides.property.functionProps">functionProps</a></code> | <code><a href="#cdk-nextjs.OptionalFunctionProps">OptionalFunctionProps</a></code> | *No description.* |
5422
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionOverrides.property.functionUrlProps">functionUrlProps</a></code> | <code><a href="#cdk-nextjs.OptionalFunctionUrlProps">OptionalFunctionUrlProps</a></code> | *No description.* |
5423
+
5424
+ ---
5425
+
5426
+ ##### `functionProps`<sup>Optional</sup> <a name="functionProps" id="cdk-nextjs.NextjsImageFunctionOverrides.property.functionProps"></a>
5427
+
5428
+ ```typescript
5429
+ public readonly functionProps: OptionalFunctionProps;
5430
+ ```
5431
+
5432
+ - *Type:* <a href="#cdk-nextjs.OptionalFunctionProps">OptionalFunctionProps</a>
5433
+
5434
+ ---
5435
+
5436
+ ##### `functionUrlProps`<sup>Optional</sup> <a name="functionUrlProps" id="cdk-nextjs.NextjsImageFunctionOverrides.property.functionUrlProps"></a>
5437
+
5438
+ ```typescript
5439
+ public readonly functionUrlProps: OptionalFunctionUrlProps;
5440
+ ```
5441
+
5442
+ - *Type:* <a href="#cdk-nextjs.OptionalFunctionUrlProps">OptionalFunctionUrlProps</a>
5443
+
5444
+ ---
5445
+
5446
+ ### NextjsImageFunctionProps <a name="NextjsImageFunctionProps" id="cdk-nextjs.NextjsImageFunctionProps"></a>
5447
+
5448
+ #### Initializer <a name="Initializer" id="cdk-nextjs.NextjsImageFunctionProps.Initializer"></a>
5449
+
5450
+ ```typescript
5451
+ import { NextjsImageFunctionProps } from 'cdk-nextjs'
5452
+
5453
+ const nextjsImageFunctionProps: NextjsImageFunctionProps = { ... }
5454
+ ```
5455
+
5456
+ #### Properties <a name="Properties" id="Properties"></a>
5457
+
5458
+ | **Name** | **Type** | **Description** |
5459
+ | --- | --- | --- |
5460
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionProps.property.imageOptimizationAssetPath">imageOptimizationAssetPath</a></code> | <code>string</code> | Absolute path to the asset prepared by `NextjsBuild`: bundled handler, glibc `sharp` binaries, and `required-server-files.json`. |
5461
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionProps.property.nextjsType">nextjsType</a></code> | <code><a href="#cdk-nextjs.NextjsType">NextjsType</a></code> | *No description.* |
5462
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionProps.property.staticAssetsBucket">staticAssetsBucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | S3 bucket containing static assets, read by the handler to serve non-absolute image URLs. |
5463
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionProps.property.overrides">overrides</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionOverrides">NextjsImageFunctionOverrides</a></code> | Override props of any construct. |
5464
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionProps.property.staticAssetsKeyPrefix">staticAssetsKeyPrefix</a></code> | <code>string</code> | S3 key prefix the static assets were uploaded under, i.e. `NextjsStaticAssets.keyPrefix`, which namespaces a shared bucket. |
5465
+ | <code><a href="#cdk-nextjs.NextjsImageFunctionProps.property.vpc">vpc</a></code> | <code>aws-cdk-lib.aws_ec2.IVpc</code> | *No description.* |
5466
+
5467
+ ---
5468
+
5469
+ ##### `imageOptimizationAssetPath`<sup>Required</sup> <a name="imageOptimizationAssetPath" id="cdk-nextjs.NextjsImageFunctionProps.property.imageOptimizationAssetPath"></a>
5470
+
5471
+ ```typescript
5472
+ public readonly imageOptimizationAssetPath: string;
5473
+ ```
5474
+
5475
+ - *Type:* string
5476
+
5477
+ Absolute path to the asset prepared by `NextjsBuild`: bundled handler, glibc `sharp` binaries, and `required-server-files.json`.
5478
+
5479
+ > [{@link NextjsBuild.imageOptimizationAssetPath }]({@link NextjsBuild.imageOptimizationAssetPath })
5480
+
5481
+ ---
5482
+
5483
+ ##### `nextjsType`<sup>Required</sup> <a name="nextjsType" id="cdk-nextjs.NextjsImageFunctionProps.property.nextjsType"></a>
5484
+
5485
+ ```typescript
5486
+ public readonly nextjsType: NextjsType;
5487
+ ```
5488
+
5489
+ - *Type:* <a href="#cdk-nextjs.NextjsType">NextjsType</a>
5490
+
5491
+ ---
5492
+
5493
+ ##### `staticAssetsBucket`<sup>Required</sup> <a name="staticAssetsBucket" id="cdk-nextjs.NextjsImageFunctionProps.property.staticAssetsBucket"></a>
5494
+
5495
+ ```typescript
5496
+ public readonly staticAssetsBucket: IBucket;
5497
+ ```
5498
+
5499
+ - *Type:* aws-cdk-lib.aws_s3.IBucket
5500
+
5501
+ S3 bucket containing static assets, read by the handler to serve non-absolute image URLs.
5502
+
5503
+ ---
5504
+
5505
+ ##### `overrides`<sup>Optional</sup> <a name="overrides" id="cdk-nextjs.NextjsImageFunctionProps.property.overrides"></a>
5506
+
5507
+ ```typescript
5508
+ public readonly overrides: NextjsImageFunctionOverrides;
5509
+ ```
5510
+
5511
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionOverrides">NextjsImageFunctionOverrides</a>
5512
+
5513
+ Override props of any construct.
5514
+
5515
+ ---
5516
+
5517
+ ##### `staticAssetsKeyPrefix`<sup>Optional</sup> <a name="staticAssetsKeyPrefix" id="cdk-nextjs.NextjsImageFunctionProps.property.staticAssetsKeyPrefix"></a>
5518
+
5519
+ ```typescript
5520
+ public readonly staticAssetsKeyPrefix: string;
5521
+ ```
5522
+
5523
+ - *Type:* string
5524
+
5525
+ S3 key prefix the static assets were uploaded under, i.e. `NextjsStaticAssets.keyPrefix`, which namespaces a shared bucket.
5526
+
5527
+ Threaded through explicitly rather than read from the app's bundled config,
5528
+ because it's distinct from the app's own `basePath` (which next-image-loader
5529
+ bakes into hrefs) — the two diverge when the app's `basePath` comes from
5530
+ elsewhere, e.g. an API Gateway stage under `NextjsRegionalFunctions`.
5531
+
5532
+ ---
5533
+
5534
+ ##### `vpc`<sup>Optional</sup> <a name="vpc" id="cdk-nextjs.NextjsImageFunctionProps.property.vpc"></a>
5535
+
5536
+ ```typescript
5537
+ public readonly vpc: IVpc;
5538
+ ```
5539
+
5540
+ - *Type:* aws-cdk-lib.aws_ec2.IVpc
5541
+
5542
+ ---
5543
+
4867
5544
  ### NextjsPostDeployOverrides <a name="NextjsPostDeployOverrides" id="cdk-nextjs.NextjsPostDeployOverrides"></a>
4868
5545
 
4869
5546
  #### Initializer <a name="Initializer" id="cdk-nextjs.NextjsPostDeployOverrides.Initializer"></a>
@@ -5257,6 +5934,29 @@ public readonly basePath: string;
5257
5934
 
5258
5935
  Prefix to the URI path the app will be served at.
5259
5936
 
5937
+ Also namespaces the
5938
+ static assets in S3, so it doubles as a way to host multiple apps or
5939
+ branches out of one bucket.
5940
+
5941
+ How this relates to the `basePath` in your app's `next.config.js` depends
5942
+ on the construct, and synth fails on a combination that can't serve the
5943
+ app:
5944
+
5945
+ - `NextjsGlobalFunctions`/`NextjsGlobalContainers`: leave this unset and it
5946
+ follows your app's `basePath`, which is what you want — CloudFront serves
5947
+ static assets from S3 using the request path as the object key, so the two
5948
+ have to be identical and a mismatch 404s all of them. Setting a different
5949
+ value throws.
5950
+ - `NextjsRegionalFunctions`: if you set this, the app's `basePath` must end
5951
+ with it — either equal to it, or prefixed by the stage or base path
5952
+ mapping API Gateway strips before matching resources (`basePath:
5953
+ "/prod/base"` with this set to `"/base"`). Leaving it unset while the app
5954
+ sets one is correct and common — an app served at the default `prod` stage
5955
+ sets `basePath: "/prod"` and leaves this alone.
5956
+ - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
5957
+ every path to the container, which serves its own static assets, so this
5958
+ is unconstrained.
5959
+
5260
5960
  ---
5261
5961
 
5262
5962
  *Example*
@@ -5423,8 +6123,9 @@ const nextjsRegionalFunctionsConstructOverrides: NextjsRegionalFunctionsConstruc
5423
6123
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsBuildProps">nextjsBuildProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsBuildProps">OptionalNextjsBuildProps</a></code> | *No description.* |
5424
6124
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsCacheProps">nextjsCacheProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsCacheProps">OptionalNextjsCacheProps</a></code> | *No description.* |
5425
6125
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsStaticAssetsProps">nextjsStaticAssetsProps</a></code> | <code><a href="#cdk-nextjs.NextjsStaticAssetsProps">NextjsStaticAssetsProps</a></code> | *No description.* |
5426
- | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsApiProps">nextjsApiProps</a></code> | <code><a href="#cdk-nextjs.NextjsApiProps">NextjsApiProps</a></code> | *No description.* |
5427
6126
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsFunctionsProps">nextjsFunctionsProps</a></code> | <code><a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a></code> | *No description.* |
6127
+ | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsImageFunctionProps">nextjsImageFunctionProps</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a></code> | *No description.* |
6128
+ | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsApiProps">nextjsApiProps</a></code> | <code><a href="#cdk-nextjs.NextjsApiProps">NextjsApiProps</a></code> | *No description.* |
5428
6129
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsPostDeployProps">nextjsPostDeployProps</a></code> | <code><a href="#cdk-nextjs.OptionalNextjsPostDeployProps">OptionalNextjsPostDeployProps</a></code> | *No description.* |
5429
6130
 
5430
6131
  ---
@@ -5459,23 +6160,33 @@ public readonly nextjsStaticAssetsProps: NextjsStaticAssetsProps;
5459
6160
 
5460
6161
  ---
5461
6162
 
5462
- ##### `nextjsApiProps`<sup>Optional</sup> <a name="nextjsApiProps" id="cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsApiProps"></a>
6163
+ ##### `nextjsFunctionsProps`<sup>Optional</sup> <a name="nextjsFunctionsProps" id="cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsFunctionsProps"></a>
5463
6164
 
5464
6165
  ```typescript
5465
- public readonly nextjsApiProps: NextjsApiProps;
6166
+ public readonly nextjsFunctionsProps: NextjsFunctionsProps;
5466
6167
  ```
5467
6168
 
5468
- - *Type:* <a href="#cdk-nextjs.NextjsApiProps">NextjsApiProps</a>
6169
+ - *Type:* <a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a>
5469
6170
 
5470
6171
  ---
5471
6172
 
5472
- ##### `nextjsFunctionsProps`<sup>Optional</sup> <a name="nextjsFunctionsProps" id="cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsFunctionsProps"></a>
6173
+ ##### `nextjsImageFunctionProps`<sup>Optional</sup> <a name="nextjsImageFunctionProps" id="cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsImageFunctionProps"></a>
5473
6174
 
5474
6175
  ```typescript
5475
- public readonly nextjsFunctionsProps: NextjsFunctionsProps;
6176
+ public readonly nextjsImageFunctionProps: NextjsImageFunctionProps;
5476
6177
  ```
5477
6178
 
5478
- - *Type:* <a href="#cdk-nextjs.NextjsFunctionsProps">NextjsFunctionsProps</a>
6179
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionProps">NextjsImageFunctionProps</a>
6180
+
6181
+ ---
6182
+
6183
+ ##### `nextjsApiProps`<sup>Optional</sup> <a name="nextjsApiProps" id="cdk-nextjs.NextjsRegionalFunctionsConstructOverrides.property.nextjsApiProps"></a>
6184
+
6185
+ ```typescript
6186
+ public readonly nextjsApiProps: NextjsApiProps;
6187
+ ```
6188
+
6189
+ - *Type:* <a href="#cdk-nextjs.NextjsApiProps">NextjsApiProps</a>
5479
6190
 
5480
6191
  ---
5481
6192
 
@@ -5513,6 +6224,7 @@ const nextjsRegionalFunctionsOverrides: NextjsRegionalFunctionsOverrides = { ...
5513
6224
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsStaticAssets">nextjsStaticAssets</a></code> | <code><a href="#cdk-nextjs.NextjsStaticAssetsOverrides">NextjsStaticAssetsOverrides</a></code> | *No description.* |
5514
6225
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsApi">nextjsApi</a></code> | <code><a href="#cdk-nextjs.NextjsApiOverrides">NextjsApiOverrides</a></code> | *No description.* |
5515
6226
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsFunctions">nextjsFunctions</a></code> | <code><a href="#cdk-nextjs.NextjsFunctionsOverrides">NextjsFunctionsOverrides</a></code> | *No description.* |
6227
+ | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsImageFunction">nextjsImageFunction</a></code> | <code><a href="#cdk-nextjs.NextjsImageFunctionOverrides">NextjsImageFunctionOverrides</a></code> | *No description.* |
5516
6228
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsPostDeploy">nextjsPostDeploy</a></code> | <code><a href="#cdk-nextjs.NextjsPostDeployOverrides">NextjsPostDeployOverrides</a></code> | *No description.* |
5517
6229
  | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsRegionalFunctions">nextjsRegionalFunctions</a></code> | <code><a href="#cdk-nextjs.NextjsRegionalFunctionsConstructOverrides">NextjsRegionalFunctionsConstructOverrides</a></code> | *No description.* |
5518
6230
 
@@ -5558,6 +6270,16 @@ public readonly nextjsFunctions: NextjsFunctionsOverrides;
5558
6270
 
5559
6271
  ---
5560
6272
 
6273
+ ##### `nextjsImageFunction`<sup>Optional</sup> <a name="nextjsImageFunction" id="cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsImageFunction"></a>
6274
+
6275
+ ```typescript
6276
+ public readonly nextjsImageFunction: NextjsImageFunctionOverrides;
6277
+ ```
6278
+
6279
+ - *Type:* <a href="#cdk-nextjs.NextjsImageFunctionOverrides">NextjsImageFunctionOverrides</a>
6280
+
6281
+ ---
6282
+
5561
6283
  ##### `nextjsPostDeploy`<sup>Optional</sup> <a name="nextjsPostDeploy" id="cdk-nextjs.NextjsRegionalFunctionsOverrides.property.nextjsPostDeploy"></a>
5562
6284
 
5563
6285
  ```typescript
@@ -5658,6 +6380,29 @@ public readonly basePath: string;
5658
6380
 
5659
6381
  Prefix to the URI path the app will be served at.
5660
6382
 
6383
+ Also namespaces the
6384
+ static assets in S3, so it doubles as a way to host multiple apps or
6385
+ branches out of one bucket.
6386
+
6387
+ How this relates to the `basePath` in your app's `next.config.js` depends
6388
+ on the construct, and synth fails on a combination that can't serve the
6389
+ app:
6390
+
6391
+ - `NextjsGlobalFunctions`/`NextjsGlobalContainers`: leave this unset and it
6392
+ follows your app's `basePath`, which is what you want — CloudFront serves
6393
+ static assets from S3 using the request path as the object key, so the two
6394
+ have to be identical and a mismatch 404s all of them. Setting a different
6395
+ value throws.
6396
+ - `NextjsRegionalFunctions`: if you set this, the app's `basePath` must end
6397
+ with it — either equal to it, or prefixed by the stage or base path
6398
+ mapping API Gateway strips before matching resources (`basePath:
6399
+ "/prod/base"` with this set to `"/base"`). Leaving it unset while the app
6400
+ sets one is correct and common — an app served at the default `prod` stage
6401
+ sets `basePath: "/prod"` and leaves this alone.
6402
+ - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
6403
+ every path to the container, which serves its own static assets, so this
6404
+ is unconstrained.
6405
+
5661
6406
  ---
5662
6407
 
5663
6408
  *Example*
@@ -10389,10 +11134,11 @@ const optionalNextjsDistributionProps: OptionalNextjsDistributionProps = { ... }
10389
11134
  | **Name** | **Type** | **Description** |
10390
11135
  | --- | --- | --- |
10391
11136
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.assetsBucket">assetsBucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | Bucket containing static assets. |
10392
- | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.basePath">basePath</a></code> | <code>string</code> | *No description.* |
11137
+ | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.basePath">basePath</a></code> | <code>string</code> | URI path prefix the app is served at. |
10393
11138
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.certificate">certificate</a></code> | <code>aws-cdk-lib.aws_certificatemanager.ICertificate</code> | Optional but only applicable for `NextjsType.GLOBAL_CONTAINERS`. |
10394
11139
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.distribution">distribution</a></code> | <code>aws-cdk-lib.aws_cloudfront.Distribution</code> | *No description.* |
10395
11140
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.functionUrl">functionUrl</a></code> | <code>aws-cdk-lib.aws_lambda.IFunctionUrl</code> | Required if `NextjsType.GLOBAL_FUNCTIONS`. |
11141
+ | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.imageFunctionUrl">imageFunctionUrl</a></code> | <code>aws-cdk-lib.aws_lambda.IFunctionUrl</code> | Function URL of the dedicated image optimization Lambda. |
10396
11142
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.loadBalancer">loadBalancer</a></code> | <code>aws-cdk-lib.aws_elasticloadbalancingv2.IApplicationLoadBalancer</code> | Required if `NextjsType.GLOBAL_CONTAINERS` or `NextjsType.REGIONAL_CONTAINERS`. |
10397
11143
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.nextjsType">nextjsType</a></code> | <code><a href="#cdk-nextjs.NextjsType">NextjsType</a></code> | *No description.* |
10398
11144
  | <code><a href="#cdk-nextjs.OptionalNextjsDistributionProps.property.publicDirEntries">publicDirEntries</a></code> | <code><a href="#cdk-nextjs.PublicDirEntry">PublicDirEntry</a>[]</code> | Entries (files/directories) within Next.js app's public directory. Used to add static behaviors to distribution. |
@@ -10421,6 +11167,11 @@ public readonly basePath: string;
10421
11167
 
10422
11168
  - *Type:* string
10423
11169
 
11170
+ URI path prefix the app is served at.
11171
+
11172
+ Surrounding slashes are normalized
11173
+ away, so "/base", "base" and "/base/" all produce the same cache behaviors.
11174
+
10424
11175
  ---
10425
11176
 
10426
11177
  ##### `certificate`<sup>Optional</sup> <a name="certificate" id="cdk-nextjs.OptionalNextjsDistributionProps.property.certificate"></a>
@@ -10457,6 +11208,24 @@ Required if `NextjsType.GLOBAL_FUNCTIONS`.
10457
11208
 
10458
11209
  ---
10459
11210
 
11211
+ ##### `imageFunctionUrl`<sup>Optional</sup> <a name="imageFunctionUrl" id="cdk-nextjs.OptionalNextjsDistributionProps.property.imageFunctionUrl"></a>
11212
+
11213
+ ```typescript
11214
+ public readonly imageFunctionUrl: IFunctionUrl;
11215
+ ```
11216
+
11217
+ - *Type:* aws-cdk-lib.aws_lambda.IFunctionUrl
11218
+
11219
+ Function URL of the dedicated image optimization Lambda.
11220
+
11221
+ Only applicable
11222
+ to `NextjsType.GLOBAL_FUNCTIONS`, and only when the dedicated image
11223
+ function is enabled. When omitted, the `_next/image*` behavior points at
11224
+ the dynamic origin, which serves image optimization from the Next.js
11225
+ server itself.
11226
+
11227
+ ---
11228
+
10460
11229
  ##### `loadBalancer`<sup>Optional</sup> <a name="loadBalancer" id="cdk-nextjs.OptionalNextjsDistributionProps.property.loadBalancer"></a>
10461
11230
 
10462
11231
  ```typescript