Bundle size doubled with no obvious cause

A practical fix and a copyable AI coding prompt. Replace bracketed placeholders with your project details.

1. Check the problem

Run `next build` for the route-level kB breakdown, then `npx @next/bundle-analyzer` for a visual. Usual culprits: a heavy library in a layout, a non-tree-shaken icon set, or a server-only module pulled into a client component.

2. Use the prompt

My Next.js bundle size jumped with no obvious cause. Show me how to read the route-level kB breakdown from next build and run the bundle analyzer, then help me find the culprit: a heavy lib imported in a layout, a non-tree-shaken icon set, or a server-only module pulled into a client component. Point at the import to change.

3. Verify the fix

Review the proposed diff, run the relevant checks and exercise the original failing flow before merging.

Continue in the related workflow chapter.