Description
Goal:
I am trying to create a standalone .exe
(Windows executable) bundle of a Next.js application. My goal is to package the entire app, along with the Node.js runtime, into a single executable file that can be run on a Windows machine without requiring Node.js to be installed.
What I've Tried:
I've followed the Next.js standalone export process (output: 'standalone'
) and attempted to bundle it using the Node.js Self-Extracting Archive (SEA) feature, as described in the [official Node SEA documentation](https://nodejs.org/api/single-executable-applications.html). This process is relatively new and intended to replace older tools like pkg
and nexe
.
Previously, I was able to generate .exe
files using:
However, both of these tools are now either unmaintained or lacking support for modern Node.js features and complex setups like those involving Next.js and ES modules.
Challenges:
- While I can get a working output using
next build
withoutput: 'standalone'
, integrating this with the SEA approach is proving difficult. - The SEA process requires setting up a bootstrap loader script (
loader.js
), embedding it into a Node binary, and including theblob
containing the app code. - Next.js apps have complex file structures (e.g., dynamic imports, middleware, server components), which makes packaging and referencing assets non-trivial.
- There’s little guidance available on combining Next.js with SEA to generate an actual Windows
.exe
file.
What I’m Looking For:
I need a reliable, maintainable method for turning a Next.js application into a Windows executable using:
- Modern tooling (preferably SEA or other actively maintained methods),
- Node.js 18+ compatibility, and
- Support for standalone server builds generated by Next.js.
If anyone has successfully used Node SEA with a Next.js app, or has a working example or boilerplate for generating .exe
files from a standalone build, I’d greatly appreciate any guidance or resources you could share.