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
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?
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.
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
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With