Next.js 8

Next.js 8

Next.js 8 introduces Serverless Mode, smaller bundles, performance improvements, and more.

Next.js 8 introduces Serverless Mode, smaller bundles, performance improvements, and more.

We are proud today to introduce the production-ready Next.js 8, featuring:

As always, we have strived to ensure all these benefits are completely backwards compatible. For most Next.js applications, all you need to do is run:

npm i [email protected] [email protected] [email protected]

We are thankful to our community and everyone who has bet on our success. Since our last blog post, we have seen companies like AT&T, Starbucks and Twitch relaunch their public-facing websites and apps with Next.js.

Serverless Next.js

Serverless deployment dramatically improves reliability and scalability by splitting your application into smaller parts (also called lambdas). In the case of Next.js, each page in the pages directory becomes a serverless lambda.

There are a number of benefits to serverless. The referenced link talks about some of them in the context of Express, but the principles apply universally: serverless allows for distributed points of failure, infinite scalability, and is incredibly affordable with a “pay for what you use” model.

To enable serverless mode in Next.js, add the serverless build target in next.config.js:

// next.config.js
module.exports = {
  target: "serverless",

The serverless target will output a single lambda per page. This file is completely standalone and does not require any dependencies to run:

The signature of the Next.js Serverless function is similar to the Node.js HTTP server callback:

export function render(req: http.IncomingMessage, res: http.ServerResponse) => void

Next.js provides low-level APIs for serverless deployments as hosting platforms have different function signatures. In general you will want to wrap the output of a Next.js serverless build with a compatibility layer.

For example if the platform supports the Node.js http.Server class:

const http = require("http");
const page = require("./.next/serverless/about.js");
const server = new http.Server((req, res) => page.render(req, res));
server.listen(3000, () => console.log("Listening on http://localhost:3000"));


We have contributed to webpack to improve Next.js’s (and the rest of the webpack ecosystem’s!) build performance and resource utilization.

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).

Build-time environment configuration

While reviewing Next.js applications an often reoccurring pattern we observed was adding babel-plugin-transform-define or webpack.DefinePlugin to provide configuration values to the application.

With Next.js 8 we are introducing a new key to next.config.js named env to provide the same functionality in a backward compatible way:

// next.config.js
module.exports = {
  env: {
    customKey: 'MyValue'

This will allow you to use process.env.customKey in your code. For example:

// pages/index.js
export default function IndexPage() {
  return <h1>The value of customKey is: {process.env.customKey}</h1>

process.env.customKey will be replaced with 'MyValue' at build time.

Prefetch performance improvements

The Next.js router allows you to prefetch pages for faster navigation:

import Link from 'next/link'

export default function IndexPage() {
  return <>
    <Link href="/about" prefetch>
      <a>To About Page</a>

It works by prefetching the Javascript bundle of every link that has a prefetch attribute.

In versions before Next.js 8 this would mean injecting a

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top 7 Most Popular Node.js Frameworks You Should Know

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser. In this post, you'll see top 7 of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).

Node.js for Beginners - Learn Node.js from Scratch (Step by Step)

Node.js for Beginners - Learn Node.js from Scratch (Step by Step) - Learn the basics of Node.js. This Node.js tutorial will guide you step by step so that you will learn basics and theory of every part. Learn to use Node.js like a professional. You’ll learn: Basic Of Node, Modules, NPM In Node, Event, Email, Uploading File, Advance Of Node.

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.