Bringing Electron applications to millions of Linux users

by Alan Pope on 26 July 2018

Electron is one of the most popular frameworks for creating cross-platform desktop applications right now. Many developers use electron-builder to do the heavy-lifting of package management for their Electron apps.

electron-builder has support for creating snap packages out of the box. Bringing your Electron desktop app to Linux can be as simple as a one-line change in your package.json. Here we’ll use an existing application – BitWarden – to show you how.

BitWarden is a cross-platform password store featuring secure cloud sync across their desktop and mobile clients. The desktop client is available for Linux in the snap store.

The source for BitWarden is on GitHub, but that’s not a requirement for building snaps. It just makes it easier for us to point out how they implemented the snap build. BitWarden are currently using electron builder 20.8.1 or later,

"devDependencies": {
"electron-builder": "^20.8.1",

In the "linux" section of the package.json the BitWarden developers added a 'snap' build target. This is alongside the other build targets the developers have chosen to support.

"linux": {
"category": "Utility",
"synopsis": "A secure and free password manager for all of your devices.",
"target": [

For many electron applications this one line is enough to generate a working snap! Simply build as you normally do either locally or using a remote service such as Travis or CircleCI and this will produce a snap.

electron-builder exposes additional snap features via an optional 'snap' stanza in the package.json. For example the BitWarden application requires an additional interface to access the password management service, and an additional package to be staged inside the snap.

Interfaces are comprised of plugs and slots at each end, so the term ‘plugs’ allows you to specify a list of interfaces you want to enable in the snap. The 'stagePackages' section allows you to specify debs from the Ubuntu 16.04 archive which will be pulled into the snap at build time.

"snap": {
"confinement": "strict",
"plugs": [
"stagePackages": [

That’s it! The full package.json can be found in the BitWarden GitHub repo.

The community of developers building snap, snapcraft and snaps hang out on the snapcraft forums. Join us!

Newsletter Signup

Related posts

How to make your first snap

Snaps are a way to package your software so it is easy to install on Linux. If you’re a snap developer already or you’re a part of the Linux community, and you care about how software is deployed, and you’re well versed in how software is packaged, and are tuned into the discussions around packaging […]

What’s in a snap?

Snaps are several things, all at once. They are confined, standalone Linux applications that bundle all their necessary dependencies, which means they do not need to rely on the underlying system, and can run independently of it. Snaps are also packaged as compressed Squashfs filesystems, using the .snap extension. For most users, they ar […]

How does Ubuntu 16.04 entering Extended Security Maintenance (ESM) affect snap publishers?

At the end of April, Ubuntu 16.04 LTS will reach the end of its five years of mainstream support and enter the Extended Security Maintenance (ESM) phase. If you’re a snap developer, and you have built or based your snaps on Ubuntu 16.04 (Xenial) packages and libraries, you may want to know how this milestone […]