Convert Websites to Native Apps

Converting a website to a native app, whether on mobile or desktop, can be quite useful.  The problem with bookmarks, especially for software engineers, is that we often need to work in different browsers, so having everything in one browser’s bookmark set can be a pain.  I’d also argue that websites with a specific purpose are great case for converting a website to desktop app.  I recently found Nativefier, an open source utility that creates a native desktop app by wrapping the site in Electron.

  • Installation

You can use NPM to install nativefier and node-icns, which we’ll use to create a custom icon for the app:

npm install -g nativefier # App creator
npm install -g node-icns  # Icon creator

The nativefier docs provide a method for creating the desktop app icon but ImageMagick and iconutils are required — node-icns will save you some pain.

  • Create the App Icon

It’s important to create the app icon before creating the app itself. You can create an app icon with node-icns and an image of your choice:

nicns --in app-icon.png --out app-icon.icns

Use a high-quality, square-shaped PNG — transparency will be preserved and file size doesn’t matter since the files will live on your machine.

  • Creating the App

nativefier provides a whole host of configuration parameters you can use to create your app.  Let’s create an app using many of the useful parameters:

    --name "My Blog" 
    --icon app-icons.icns 
    --inject custom-css.css 
    --inject custom-js.js 
    --flash # gross

A directory named “{appname}-darwin-x64” will be generated and within that directory will be the app file, which you can drag to your Applications folder (or whatever your OS equivalent is) and to your dock.  You’ll note that you can add custom user JavaScript and CSS files so that you can hide advertisements, modify colors and behavior, and so on.  The —counter argument is particularly interesting — a web app like Gmail that updates its <title> tag as a pseudo-notification will trigger a red notification dot over the app icon when an update is made.

Web apps like IRCCloud and websites like DevDocs are perfect candidates for conversion to desktop app.

Leave a comment

Your email address will not be published. Required fields are marked *