lagon
lagon copied to clipboard
Support Next.js
Support Next.js SSR with the new Edge Runtime.
- [x]
pages
directory - [x]
app
directory with React Server Components & streaming - [ ] Integration in the CLI to bundle all the edge functions in a single one
Update: both the pages
directory and the app
directory are working!
https://twitter.com/tomlienard/status/1613229200789438464
Update: created #612 because Next.js now expects AsyncLocalStorage
to be present in the global scope.
Update: AsyncLocalStorage
has been merged for a few weeks, but Next.js now expects the runtime to support imports (and specifically an implementation of Buffer
from node:buffer
), which we don’t have at all right now and would make the runtime even more complicated.
https://twitter.com/ascorbic/status/1648264283824742401?s=46&t=vptTziexWvl21M22w1Jv0w
Any reason not leveraging unjs/unenv or nitro to bundle output?
Great question! Implementing these APIs (AsyncLocalStorage
, Buffer
...) should be done in the runtime itself because it needs to be very performant. They will ultimately be implemented natively (instead of in JS-land right now) so it doesn't really make sense to use unenv now and remove it later.
Yes makes sense for ALS cannot be implemented in Userland. (unenv will also auto-detect such environments and use native soon. It only has a shim. But Buffer
and other Node.js APIs used by next.js or user dependencies can possibly use can be leveraged unenv userland impl same as Nuxt.