Next.js 13.5: Faster Dev, Optimized Imports, Enhanced Images

September 19, 20234 min read
Next.js 13.5: Faster Dev, Optimized Imports, Enhanced Images

Next.js, the popular React framework, has released its latest version, Next.js 13.5, with significant improvements in local development performance and reliability. This update brings a range of enhancements, including faster server startup, improved Hot Module Replacement (HMR), reduced memory usage, optimized package imports, and improvements to the next/image component. Additionally, over 438 bugs have been patched in this release. Let's dive into the details of these improvements and explore how they can benefit developers.

Improving Startup and Fast Refresh Time

One of the key focus areas of Next.js 13.5 is enhancing local development performance. The team at Next.js has made impressive progress in this aspect, resulting in significant speed improvements. The local server startup time is now 22% faster, allowing developers to iterate more quickly. Additionally, the HMR (Fast Refresh) feature, which enables faster iterations when saving changes, has been optimized and is now 29% faster. These improvements make the development experience smoother and more efficient.

To achieve these performance enhancements, Next.js has implemented various optimizations. They have reduced the amount of work done during server startup by caching or minimizing slow operations. Expensive file system operations have been optimized, and better incremental tree traversal has been introduced during compilation. Unnecessary blocking synchronous calls have been made lazy, further improving startup time and fast refresh.

Optimized Package Imports

Next.js 13.5 introduces a breakthrough in optimizing package imports, which significantly improves local development performance and production cold starts. When using large icons or component libraries, or other dependencies that re-export hundreds or thousands of modules, Next.js now automatically optimizes the imports. This optimization results in faster updates and improved performance.

Previously, developers had to configure imports using the modularizeImports option. However, Next.js 13.5 introduces a new and more convenient approach called optimizePackageImports. With this approach, developers no longer need to specify the mapping of imports manually. Libraries like @mui/icons-material, @mui/material, date-fns, lodash, lodash-es, ramda, react-bootstrap, @headlessui/react, @heroicons/react, and lucide-react are now automatically optimized. This optimization ensures that only the modules being used are loaded, while still allowing developers to write import statements with many named exports.

next/image Improvements

Based on community feedback, Next.js 13.5 introduces several improvements to the next/image component. This component is widely used for optimizing images in Next.js applications. The latest version adds a new experimental function called unstable_getImgProps(), which allows advanced use cases without directly using the next/image component.

Developers can now work with background-image or image-set using unstable_getImgProps(). It also enables working with canvas context.drawImage() or new Image(). Moreover, developers can use `<picture>` media queries to implement art direction or Light/Dark Mode images.

Here's an example of how to use unstable_getImgProps():

Additionally, the placeholder prop now supports providing arbitrary data:image/ for placeholder images that shouldn't be blurred.

Other Improvements

Next.js 13.5 comes with numerous bug fixes and improvements, totaling over 438 patches. These fixes address various issues reported by the community, ensuring a more stable and reliable development experience. The Next.js team is committed to continuously improving the framework and addressing user feedback.

Upgrade to Next.js 13.5

Next.js 13.5 brings substantial performance and reliability improvements, making it an essential upgrade for developers. The faster local server startup, improved HMR, reduced memory usage, optimized package imports, and enhancements to the next/image component all contribute to a better development experience. Additionally, the numerous bug fixes and improvements provide a more stable foundation for building Next.js applications.

To upgrade to Next.js 13.5, developers can run the following command:

Next.js Conf, a conference dedicated to Next.js, is also on the horizon. It will take place on October 26, 2023, and offers an excellent opportunity to learn more about the latest advancements in Next.js.

In conclusion, Next.js 13.5 is a significant release that brings substantial improvements to local development performance and reliability. Developers can benefit from faster server startup, improved HMR, optimized package imports, and enhanced next/image functionality. With over 438 bugs fixed, Next.js continues to provide a stable and reliable framework for building modern web applications. Upgrade to Next.js 13.5 and experience the improved development experience it offers.

Read more posts

The new Form Component from Next.js 15

The new Form Component from Next.js 15

October 28, 20242 min read
Next.js 15 has just released and it has come with a new Form Component. This new Form Component is especially useful for forms that redirect to a new url for example when you try to search for blog posts and that redirects to a page that displays all the blog posts with that specific query.
Astro 3.0 has made waves in the web development community

Astro 3.0 has made waves in the web development community

September 10, 20245 min read
Astro 3.0 has made waves in the web development community as the first major framework to support the View Transitions API. This groundbreaking feature allows for seamless and visually appealing transitions between different states or views in web applications. With just a few lines of code, developers can easily incorporate fade, slide, morph, and persist animations across page navigation, creating a more immersive user experience.
Testing Next.js Apps: Best Practices & Tools

Testing Next.js Apps: Best Practices & Tools

August 15, 20247 min read
Testing is an essential part of the software development process, ensuring that applications function as expected and remain stable over time. In this blog, we will explore the best practices for testing Next.js applications using popular testing tools like Jest, Cypress, Playwright, and React Testing Library. By following these guidelines, you can maximize your confidence in your code, catch bugs early, and deliver high-quality software to your users.
React Compiler: what does it do and what's new

React Compiler: what does it do and what's new

June 9, 20243 min read
The React Compiler is a experimental compiler that has been open sources to the community in order to receive feedback and ideas. As you can imagine this means it is not production ready yet. However, it is a great way to get a feel for what this compiler of React does and can do. Keep in mind that this experimental compiler needs React 19 to work.