Skip to content

Commit ddd3717

Browse files
HuiSFjimblancjosefaidt
authored
chore: add serverComponentsExternalPackages callout for Next.js (#7757)
* chore: add serverComponentsExternalPackages callout for Next.js * Apply suggestions from code review Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com> * Apply suggestions from code review * Update src/pages/gen1/[platform]/build-a-backend/server-side-rendering/nextjs/index.mdx Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com> * Update src/pages/gen1/[platform]/build-a-backend/server-side-rendering/nextjs/index.mdx Co-authored-by: josef <josef.aidt@gmail.com> * Update src/pages/[platform]/build-a-backend/server-side-rendering/index.mdx Co-authored-by: josef <josef.aidt@gmail.com> --------- Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com> Co-authored-by: josef <josef.aidt@gmail.com>
1 parent f75809d commit ddd3717

File tree

2 files changed

+48
-0
lines changed
  • src/pages
    • [platform]/build-a-backend/server-side-rendering
    • gen1/[platform]/build-a-backend/server-side-rendering/nextjs

2 files changed

+48
-0
lines changed

src/pages/[platform]/build-a-backend/server-side-rendering/index.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,30 @@ For the **GraphQL API** category, review [Connect to data from Server-side Runti
230230

231231
</Callout>
232232

233+
<Callout>
234+
235+
**Note:** If you use the Amplify server-side APIs in a [server action](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations) and encounter the following error running `next build`:
236+
237+
> ./node_modules/@aws-amplify/core/node_modules/@aws-crypto/sha256-js/build/module/index.js + 12 modules
238+
239+
> Cannot get final name for export 'fromUtf8' of ./node_modules/@smithy/util-utf8/dist-es/index.js
240+
241+
You can add the following to your `next.config.js`:
242+
243+
```ts title="next.config.js"
244+
/** @type {import('next').NextConfig} */
245+
const nextConfig = {
246+
// highlight-start
247+
experimental: {
248+
serverComponentsExternalPackages: ['@aws-crypto'],
249+
},
250+
// highlight-end
251+
};
252+
```
253+
254+
See Next.js documentation on [`serverComponentsExternalPackages`](https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages) for more details.
255+
</Callout>
256+
233257
### With Next.js App Router
234258

235259
#### Dynamic rendering in React server component

src/pages/gen1/[platform]/build-a-backend/server-side-rendering/nextjs/index.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,30 @@ For the **GraphQL API** category, review [Connect to GraphQL API from server-sid
232232

233233
</Callout>
234234

235+
<Callout>
236+
237+
**Note:** If you use the Amplify server-side APIs in a [server action](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations) and encounter the following error running `next build`:
238+
239+
> ./node_modules/@aws-amplify/core/node_modules/@aws-crypto/sha256-js/build/module/index.js + 12 modules
240+
241+
> Cannot get final name for export 'fromUtf8' of ./node_modules/@smithy/util-utf8/dist-es/index.js
242+
243+
You can add the following to your `next.config.js`:
244+
245+
```ts title="next.config.js"
246+
/** @type {import('next').NextConfig} */
247+
const nextConfig = {
248+
// highlight-start
249+
experimental: {
250+
serverComponentsExternalPackages: ['@aws-crypto'],
251+
},
252+
// highlight-end
253+
};
254+
```
255+
256+
See Next.js documentation on [`serverComponentsExternalPackages`](https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages) for more details.
257+
</Callout>
258+
235259
### With Next.js App Router
236260

237261
#### In React Server Component

0 commit comments

Comments
 (0)