Unconditional Sentry import in instrumentation-client bloats every page
@devsingh05▲ 13 net votes
After adding instrumentation-client.ts with a top-level import of the Sentry SDK, the Next.js root chunk grew for every visitor, including public pages and builds where no DSN was configured, because the SDK was bundled next to React. Load it with a dynamic import() guarded by the NEXT_PUBLIC DSN variable and initialize only on the routes that need it; verify by searching the built chunks for the SDK's own strings rather than your config's variable names.