We are supported by readers, when you click & purchase through links on our site we earn affiliate commission. Learn more.

JavaScript framework: Next.js 12 presents new Rust compiler

The React framework Next.js has reached version 12. According to the company behind it, Vercel, the biggest Next.js release has SWC on board as a new compiler and middleware as a beta function. In addition, some features of the upcoming version React 18 can now be used. The major release also contains breaking changes: these include the removal of webpack 4 after Next.js 11 had already declared webpack 5 the standard, and the increase in the required Node.js version to at least 12.22.0.

In Next.js 12, the JavaScript / TypeScript compiler written in Rust solves SWC (Speedy Web Compiler) the previously used compiler Babel. The web build tool Parcel and the JavaScript / TypeScript runtime Deno already rely on SWC. The associated native compilation is intended to significantly shorten the build and refresh times in Next.js.

According to Vercel, when deployed with large Next.js code bases, SWC can deliver up to three times faster refreshes and up to five times faster builds. The compilation with Rust, activated by default in version 12, should run 17 times faster than with Babel, with which the new compiler is backwards compatible.

The JavaScript library React has been in major version 17 for a year, a release without any new features. However, these should be included in React 18, currently available as an alpha version. In Next.js 12 their features can be used with npm install react@alpha react-dom@alpha use experimentally.

React 18 will include automatic batching of updates and a new streaming API for server-side rendering using React.lazy bring along. The React Working Group holds developers informed about new plans.

The middleware function is available as beta in Next.js 12 to execute code according to the motto “Code over Configuration” before a request is completed. Based on the incoming request from a user, the reaction can be modified, for example by a redirect or adding a header. Middleware should be suitable for various application areas such as authentication, protection against bots, feature flags or A / B testing. How it works, shows the documentation.

Next.js runs on macOS, Windows including Windows Subsystem for Linux (WSL) and Linux. A migration guide provides informationWhat to look out for when upgrading to version 12.

All other information about the new major version can be found in a blog entry.


To home page