HaNdTriX / next-electron-server

Server your Next.js app inside electron using a custom scheme.
https://npmjs.com/package/next-electron-server
27 stars 6 forks source link

What's the difference between this and vercel/serve? #5

Open hidesminimally opened 3 years ago

hidesminimally commented 3 years ago

Hi there!

I'm looking to solve a problem that I have with rendering my exported Next.js app through Electron: https://github.com/vercel/next.js/issues/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.

HaNdTriX commented 3 years ago

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:


Looking at https://github.com/vercel/next.js/issues/2581 I believe next-electron-server is what you where looking for.

kmturley commented 2 years ago

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