Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add serverComponentsExternalPackages callout for Next.js #7757

Merged
merged 6 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,30 @@ For the **GraphQL API** category, review [Connect to data from Server-side Runti

</Callout>

<Callout>

**NOTE:** If you use the Amplify server-side APIs in a server action and encounter the following error running `next build`:
HuiSF marked this conversation as resolved.
Show resolved Hide resolved

> ./node_modules/@aws-amplify/core/node_modules/@aws-crypto/sha256-js/build/module/index.js + 12 modules

> Cannot get final name for export 'fromUtf8' of ./node_modules/@smithy/util-utf8/dist-es/index.js

You can add the following to your `next.config.js`:

```ts title="next.config.js"
/** @type {import('next').NextConfig} */
const nextConfig = {
// highlight-start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these comments needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for highlighting the section that is actually needed.

experimental: {
serverComponentsExternalPackages: ['@aws-crypto'],
},
// highlight-end
};
```

See Next.js documentation on [`serverComponentsExternalPackages`](https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages) for more details.
</Callout>

### With Next.js App Router

#### Dynamic rendering in React server component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,30 @@ For the **GraphQL API** category, review [Connect to GraphQL API from server-sid

</Callout>

<Callout>

**NOTE:** If you use the Amplify server-side APIs in a server action and encounter the following error running `next build`:
HuiSF marked this conversation as resolved.
Show resolved Hide resolved

> ./node_modules/@aws-amplify/core/node_modules/@aws-crypto/sha256-js/build/module/index.js + 12 modules

> Cannot get final name for export 'fromUtf8' of ./node_modules/@smithy/util-utf8/dist-es/index.js

You can add the following to your `next.config.js`:

```ts title="next.config.js"
/** @type {import('next').NextConfig} */
const nextConfig = {
// highlight-start
experimental: {
serverComponentsExternalPackages: ['@aws-crypto'],
},
// highlight-end
};
```

See Next.js documentation on [`serverComponentsExternalPackages`](https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages) for more details.
</Callout>

### With Next.js App Router

#### In React Server Component
Expand Down