Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Next.js 8 Static Site Framework Adds Serverless Support

Next.js 8 Static Site Framework Adds Serverless Support

This item in japanese

The Next.js team recently released version 8 of their static site generation framework, improving reliability and scalability through the splitting of applications into smaller parts for use with cloud services such as AWS lambda and ZEIT Now lambdas.

Function-as-Service (FaaS) "serverless" architectures are becoming increasingly used, as they provide distributed points of failure, increased scalability, and are potentially more affordable due to requirement to pay for only for the computation time consumed by an application.

Serveless mode within Next.js gets enabled with a simple target: "serverless" configuration flag, generating a Lambda per page of a static site. Due to variations between different cloud function services, developers should wrap the output from a Next.js serverless built with a compatibility layer.

The Next.js team highlights the benefits of their serverless implementation as a low-level API for serverless deployment, each page becoming a small serverless function optimized for fast cold starts with no dependencies.

As part of this release, the Next.js team also contributed improvements to webpack, providing substantial improvements to build performance and resource utilization. According to the Next.js 8 announcement:

This effort has resulted in up to 16 times better memory usage with no degradation in performance. Memory gets released much more quickly, and processes don't crash anymore under lots of stress (many pages).

Next.js 8 also improves performance as its router allows prefetching of pages for faster user navigation by prefetching the Javascript bundle for every link containing a prefetch attribute with <link rel="preload"> instead of a separate <script> tag. Prefetching now begins after the onload event, allowing the browser to manage resources more efficiently. Prefetching gets disabled on slower 2G network connections.

Next.js 8 also provides a series of developer experience improvements, including the automatic compilation only for pages actively under development, faster port listening during development, and faster static export. Each of these changes reduces the wait time for developers working with Next.js.

Next.js is open source software available under the MIT license. Contributions and feedback are encouraged via the Next.js GitHub project and should follow the Next.js contribution guidelines.

Rate this Article