In addition to middleware, the open source next.js 12.2 release also introduces a feature called On-Demand Incremental Static Regeneration (ISR). This helps to significantly accelerate the delivery of your website. In the past, organizations cached certain website pages to improve performance, but the information wasn’t always up-to-date. On-demand ISR allows you to deliver pages with up-to-date information more quickly.
Vercel itself has accelerated its development efforts over the past year thanks to a $150 million funding round the company announced in November 2021. Vercel and the next.js framework have been big benefactors as companies of all sizes have raced to support their digital transformation efforts, which often involve advanced website application functionality.
“We have seen a lot of traction in e-commerce, consumer mobile web apps like TikTok and Twitch. Most of it runs on next.js,” says Guillermo Rauch. Vercel founder and CEO told VentureBeat:
A key highlight of the next.js 12.2 update is the stable release of next.js middleware, which has been in beta since next.js 12.0 first appeared in October 2021.
“It can do everything you would expect from other middleware technologies: authentication, authorization, redirection, rewriting, personalizing and testing new features,” Rauch said.
“You can literally just add one file, middleware.ts, and start writing your logic,” says Rauch.
The middleware.ts file is in some respects an evolution of the next.js configuration file, which defines configuration parameters for deployment. Rauch pointed out that the configuration file only offers what he calls “rudimentary” options such as custom headers and redirects. With middleware, developers can build in any logic they need to run their applications, he said.
Bring middleware to the edge
For open source developers, integrating middleware configuration into application code is one thing, but enabling that configuration to run in an optimized approach is quite another.
This is where Vercel’s Edge Middleware capabilities come into play. Edge Middleware is a commercially supported service that runs next.js on the Vercel platform to provide faster performance and lower latency.
Vercel is the lead developer of the open source next.js framework and provides commercial services for supporting and delivering applications at scale. Vercel services are powered by Amazon Web Services (AWS) and Cloudflare infrastructure.
Migrating from caching to on-demand ISR
The open source next.js 12.2 update is also notable for the introduction of on-demand ISRs for web content.
Web content can be dynamically generated by a Web server, but the process can be time consuming. As such, high-traffic applications often prefer using cached or static content.
According to Rauch, with ISRs static content is updated when there is a corresponding update in the source data source for a given application. Prior to the next.js 12.2 update, the way ISRs worked was the web server periodically checking for updates.
What’s next for next.js?
The next.js 12.2 release introduces several experimental features that show the future direction of the technology.
Among the experimental features is the use of the Edge runtime. Rauch said that next.js has used the node.js runtime since its creation, but now users are using You mentioned that you have the option to use the Edge runtime compatible with the WinterCG initiative.
Mission of VentureBeat will become a digital town square for technical decision makers to gain knowledge on innovative enterprise technology and trade. Watch the briefing.