Installing Realm with Electron-Webpack

Max Alexander
1 min readJan 10, 2018

--

If you need a fast native database for your electron app then don’t look any further than Realm! It’s blazing fast and works amazingly with massive lists. Realm is a C++ database with native bindings for Node, React-Native, Swift, .NET and Android. It also boasts very useful support for TypeScript.

Today we’ll be using Realm with Electron-Webpack, a nifty tool to help you avoid the hassle of getting started.

  1. Let’s create our electron-webpack boilerplate
mkdir electron-realm && cd electron-realm# Download the Starter Contents
curl -fsSL https://github.com/electron-userland/electron-webpack-quick-start/archive/master.tar.gz | tar -xz --strip-components 1

2. Install realm as a depedency with either npm or yarn

npm install realm --save

or if you use yarn

yarn add realm

3. Add electron-builder as a dev dependency. This dependency will help you get the right binaries for realm to work. Remember Realm is a C++ database with JavaScript/TypeScript bindings

npm install electron-builder --save-dev

or if you use yarn

yarn add electron-builder -D

4. Edit you package.json file’s “scripts” to include

"postinstall": "electron-builder install-app-deps",

5. Run npm install or yarn again to have electron-builder get the right binaries.

6. Start using Realm with your favorite Frontend Framework!

import * as Realm from 'realm'

Learn more about how to use Realm at https://realm.io/docs/javascript/latest/

--

--