7

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?

DaMatt91
  • 544
  • 1
  • 7
  • 18

2 Answers2

2

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.

daydreamer
  • 87,243
  • 191
  • 450
  • 722
1

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
};
juliomalves
  • 42,130
  • 20
  • 150
  • 146
  • Minify and fastRefresh are now not supported. It will give an error ```The root value has an unexpected property, rewritess, which is not in the list of allowed properties``` – Abdullah Mujahid Sep 01 '23 at 06:41