[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Discussions](/c/community/4)

# How to exclude specific routes during Next.js production build

9 views · 0 likes · 1 post


Vishalmahale11 (@vishalmahale11) · 2026-03-25

Hi Community ![:waving_hand:](https://emoji.discourse-cdn.com/unicode/waving_hand.png?v=15 ":waving_hand:")

## Problem
While working with `Next.js`, we are facing a challenge related to the build process. By default, `Next.js` builds all routes along with their respective `CSS` and `JS` files. Because of this, the overall bundle size becomes quite large, even when we only need a few specific routes for a particular build.

## Proposed Solution
It would be really helpful if `Next.js` allowed us to exclude certain routes during the build or build only the required routes based on the use case. This would significantly reduce bundle size and improve performance ![:rocket:](https://emoji.discourse-cdn.com/unicode/rocket.png?v=15 ":rocket:")

Has anyone faced a similar issue or found a good approach to handle this? Any suggestions would be greatly appreciated.

Thanks in advance ![:blush:](https://emoji.discourse-cdn.com/unicode/blush.png?v=15 ":blush:")