Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

next-link

Enalmada886MITdeprecated2.0.0

WARNING: This project has been renamed to next-preload-headers. Install using next-preload-headers instead.

Link header middleware for next.js static assets

next.js, http2, server push, header, link

readme

next-link

npm version

next-routes helper function copies link preload tags in head of initial response into link header where proxy will server push them. This significantly decreases the initial "time to interactive" latency for first time users.

All routes that are server push enabled must be defined in the next-routes file.

TODO:

  • send/check a cookie with buildId so we know if resources need to be pushed for this build
  • figure out how to make this work without next-routes

Usage

Add it to the express app like this:

const nextLink = require('next-link')
const routes = require("./routes");

const nextLinkRouterHandler = routes.getRequestHandler(app, ({req, res, route, query}) => {
        nextLink(app, req, res, route.page, query);
    }
);

const app = express()

app.use(nextLinkRouterHandler)