rsnext/packages/next/client/next.js
Gerald Monaco a666591555
Split up & tweak next/client initialization (#33838)
For streaming, we want the main bundle to be loaded with `async` rather than `defer`. As the first step to doing that, we need an explicit initialization step, rather than occurring as a side effect of being loaded.

For now, I've just split the logic into a `initialization` and `hydrate` (previously `initNext`) functions and called them as a side effect of `next/client/next` and `next/client/next-dev` as before. A follow-up PR will move that to a separate script tag [as recommended](https://github.com/reactwg/react-18/discussions/114).
2022-03-07 17:09:55 +00:00

14 lines
274 B
JavaScript

import { initialize, hydrate, version, router, emitter } from './'
window.next = {
version,
// router is initialized later so it has to be live-binded
get router() {
return router
},
emitter,
}
initialize({})
.then(() => hydrate())
.catch(console.error)