Next.js: HTTP/2

Created on 15 Feb 2017  路  10Comments  路  Source: vercel/next.js

I'm not familiar at all with HTTP/2, but it's advertised as being a great improvement to HTTP/1.1 (e.g in the Zeit Now docs).

So does Next.js support HTTP/2? Does something need to be configured? Should it be added to the docs? Is it automagically happening when deploying a Next.js app to Now? What about localhost development?

I don't see HTTP/2 locally (running my app with yarn dev: https://github.com/relatenow/relate):

screen shot 2017-02-15 at 14 46 43

Most helpful comment

@timneutkens what about http2 push? can i use it with nextjs? in some easy way, or i need to customize my server.js with express and put their some middlewares for http2 push, for statics

All 10 comments

HTTP/2 in most browsers works only over https so if you're f.ex. using Chrome on local dev machine you'd have to configure your dev to use SSL. Also it needs to be configured / enabled on the server side too and this depends of the server you're using.

tl;dr
I'd say HTTP/2 has nothing to do with next.

OK indeed, the version deployed on Now seems to use HTTP/2:

screen shot 2017-02-15 at 16 37 26

@sedubois when you run your app on now it will handle your requests using http2 automatically 馃槃 馃憤. We don't have to change anything next.js side for this. For other hosting solutions you might want a proxy in front of your app that handles http2.

Lol, didn't see your comment before submitting.

@timneutkens what about http2 push? can i use it with nextjs? in some easy way, or i need to customize my server.js with express and put their some middlewares for http2 push, for statics

Right, can't we use HTT2 push to increase the time to interaction?
Using script preload is already a nice improvement.

<link rel="preload" />

But can't we make it so we don't even have to wait for the HTML to be parsed by the browser to start loading the initial scripts?

capture d ecran 2018-05-04 a 10 49 35

I'm assuming we shouldn't have to wait for React to server side render the HTML page to start loading the initial scripts (green area).

@sedubois can we re-open issue?

We already add <link rel="preload" />. There's no need to re-open this issue. If you want to implement server push inside Node.js you can create a custom server to handle this.

@timneutkens Still, can't we make the client download the JavaScript while the server is generation the page? Right now, one has to happen after the other. It could save 100ms for first visits.

We should probably create a new feature request for investigating the Link header yeah.

Link: https://example.com/other/styles.css; rel=preload; as=style`
Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

sospedra picture sospedra  路  3Comments

pie6k picture pie6k  路  3Comments

havefive picture havefive  路  3Comments

swrdfish picture swrdfish  路  3Comments