What's the difference between this and vercel/serve?
Opened this issue · 2 comments
Hi there!
I'm looking to solve a problem that I have with rendering my exported Next.js app through Electron: vercel/next.js#2581
I came across this package, along with two others: https://github.com/vercel/serve and https://github.com/sindresorhus/electron-serve
I'm trying to evaluate which solution works best. Is this significantly different from vercel/serve? On the surface it seems these two packages do similar things.
Thanks in advance.
1. serve
serve
is just a very simple static web server. Afaik it has nothing to do with electron.
2. electron-serve
electron-serve
is acually pretty similar to next-electron-server. They both use so called protocol handlers to implement a way of serving files using protocols inside electron.
One important difference is that electron-serve can only serve static files wich is not suitable for working with Next.js in development mode.
3. next-electron-server
next-electron-server
was build as a glue between Next.js and Electron.
In development mode (Example) it uses electron to implement a streaming reverse proxy using a steaming protocol. This allows running Next.js and electron with all of its capabalities (Code Refresh, Devtooling, etc.
) in development.
In production mode (Example) it uses a static protocol handler to serve all Next.js pages and assets created by next export
.
For more infos please check out:
- The Example Directory
- The Electron protocol docs
Looking at vercel/next.js#2581 I believe next-electron-server is what you where looking for.
Adding another alternative for those who are interested:
4. electron-next
In development mode it uses the native NodeJS http
server along with the next.getRequestHandler()
https://github.com/leo/electron-next/blob/master/index.js#L10
In production mode it re-writes NextJS static paths for Electron handler to serve all Next.js pages and assets created by next export.
https://github.com/leo/electron-next/blob/master/index.js#L31