...Sighs in JavaScript...
If you're unable to use the app
directory with React Server Components (in beta), streaming SSR, or Suspense, but still want/need improvements to Next utilities, Next 13 with Preact is for you.
Next 13 requires Preact to add support for
renderToReadableStream
.
My approach was to achieve this with the least amount of changes to Next.js pointing back to Next 12.3.4. So I can't promise that this will work for all your use cases. I also can't promise that this will automatically work in future versions. Proceed with caution.
13.1.*
Follow the instructions in next-preact-plugin
Run patch-package
in postinstall
:
{
"scripts": {
"postinstall": "patch-package"
}
}
- Remove the check for React 18 in
next/dist/build/webpack-config.js
- Switch back to
renderToString
innext/dist/server/render.js
- Dynamic imports without
lazy
innext/dist/shared/lib/loadable.js
- Prevent running
ssr: false
loaders innext/dist/shared/lib/dynamic.js
- Prevent running