electron-squirrel-startup

Default Squirrel.Windows install/update event handler for Electron apps

Library
npm
v1.0.1
236 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
37 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 68
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
68 /100 Good
Architecture 60
Code Quality 65
Innovation 55
Learning Curve 92

electron-squirrel-startup is a tiny utility that handles the Squirrel.Windows installer lifecycle events (--squirrel-install, --squirrel-updated, --squirrel-uninstall, --squirrel-obsolete) that fire when an Electron app built for Windows is installed, updated, or removed. Requiring it at the top of an Electron app’s main process handles desktop shortcut creation/removal automatically and quits the app during these transient install-time launches, which would otherwise show a confusing flash of the app window during install.

Maintained by MongoDB (originally for Compass, MongoDB’s GUI), it has become one of the standard boilerplate dependencies scaffolded by Electron Forge and other Electron app generators for any project targeting Windows via Squirrel.

What You Get

  • Automatic desktop shortcut creation on --squirrel-install/--squirrel-updated
  • Automatic desktop shortcut removal on --squirrel-uninstall
  • Clean early exit on --squirrel-obsolete to avoid showing a stray window
  • A single boolean return value telling the caller whether to quit immediately
  • Debug logging via the debug package for troubleshooting installer events

Common Use Cases

  • Preventing an Electron app’s main window from flashing open during Windows install/update
  • Ensuring a desktop shortcut is created automatically when a Squirrel.Windows installer runs
  • Cleaning up shortcuts when a user uninstalls a Squirrel-packaged Electron app
  • Standard boilerplate included by Electron Forge’s Squirrel.Windows maker template

Under The Hood

Architecture — The entire implementation is a single index.js file: a check() function inspects process.platform and process.argv[1] for the four Squirrel command flags, and a run() helper spawns the Squirrel-provided Update.exe (located relative to the running executable) with the appropriate --createShortcut/--removeShortcut argument, quitting the Electron app once the spawned process closes. Tech Stack — Plain CommonJS JavaScript with a single runtime dependency (debug) and Electron itself as an implicit peer (via require('electron').app); tested with electron-mocha and CI’d historically via Travis and AppVeyor for cross-platform coverage. Code Quality — Given its narrow, install-time-only responsibility, the codebase is intentionally minimal (well under 50 lines) with a small dedicated test/ directory; there is no ongoing feature development expected since the Squirrel.Windows event contract it implements is stable and unchanging. API Design — The API is a single require() call whose return value doubles as a boolean signal (if (require('electron-squirrel-startup')) app.quit();), which is about as low-friction as an integration can get — it requires no configuration and is typically the very first line of an Electron app’s main process.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers