How to show an open file native dialog with Electron?

const {dialog} = require('electron').remote;

document.querySelector('#selectBtn').addEventListener('click', function (event) {
    dialog.showOpenDialog({
        properties: ['openFile', 'multiSelections']
    }, function (files) {
        if (files !== undefined) {
            // handle files
        }
    });
});

On the main process you can use

const {dialog} = require('electron');

dialog.showOpenDialog({properties: ['openFile'] }).then(function (response) {
    if (!response.canceled) {
        // handle fully qualified file name
      console.log(response.filePaths[0]);
    } else {
      console.log("no file selected");
    }
});

response looks like:

{
 canceled: false,
 filePaths: [
    '<fullpath>/<filename>'
 ]
}