Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nextjs 13 is insanely slow in dev environment

I will be very brief:

I recently switched to Nextjs 13 and I noticed it's insanely slow when I run my app on localhost via npm run dev

enter image description here

Pages even take 10 seconds and sometimes even longer to load, how it is possible?

To all who use Nextjs: do you know if it's a problem of the new version 13? did you encounter the same problem?

like image 657
DaMatt91 Avatar asked Sep 09 '25 21:09

DaMatt91


2 Answers

I had a similar issue on a big project, and for that particular issue using swc seems to have reduced the compile time for the first time a route is accessed:

const nextConfig = {
// ...
    swcMinify: true,
//...
}

There is an ongoing issue on GitHub about it, people are suggesting what have work for their particular issue.

like image 65
Faouzi Mohamed Avatar answered Sep 12 '25 15:09

Faouzi Mohamed


You can do the following things to speedup dev environment of Next.js 13+ development server.

Add the following item in next.config.js file.

module.exports = {
    fastRefresh: true,
};

You can add the following if above thing did not work in next.config.js.

module.exports = {
    concurrentFeatures: true,
};

Optimize the build configuration: Ensure that your build configuration is optimized for development. For example, you can disable certain optimizations like minification and source-maps to improve build speed during development. Review your next.config.js file and make appropriate adjustments.

Example is here in next.config.js:

module.exports = {
    productionBrowserSourceMaps: false, // Disable source maps in development
    optimizeFonts: false, // Disable font optimization
    minify: false, // Disable minification
};
like image 28
ABDUL WADOOD Avatar answered Sep 12 '25 13:09

ABDUL WADOOD