serverComponentsExternalPackages
Dependencies used inside Server Components and Route Handlers will automatically be bundled by Next.js.
If a dependency is using Node.js specific features, you can choose to opt-out specific dependencies from the Server Components bundling and use native Node.js require
.
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['@acme/ui'],
},
};
module.exports = nextConfig;
Next.js includes a short list of popular packages that currently are working on compatibility and automatically opt-ed out:
@prisma/client
@sentry/nextjs
@sentry/node
autoprefixer
aws-crt
bcrypt
cypress
eslint
express
firebase-admin
jest
lodash
mongodb
next-mdx-remote
next-seo
postcss
prettier
prisma
rimraf
sharp
shiki
sqlite3
tailwindcss
ts-node
typescript
vscode-oniguruma
webpack