Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Electron, calling dialog.showMessageBox in renderer process

Trying to get my head around getting a dialog.showMessageBox() in the render process using preload. I'm trying const {dialog} = require( 'electron') but it's returning undefined. What am I missing?

main.js:

    const consoleWindow = new BrowserWindow({
        title: 'TakServer | Console',
        width: DEBUG ? 1000 : 800,
        height: 600,
        resizable: true,
        alwaysOnTop: true,
        show: false,
        webPreferences: {
            nodeIntegration: false, 
            contextIsolation: true, n
            enableRemoteModule: false, 
            preload: path.join(__dirname, "preload.js") 
        }
    })

preload.js:


const { contextBridge, dialog } = require("electron");

console.log( "dialog", dialog ) // !!  undefined

contextBridge.exposeInMainWorld( 'api',
    {
        test: ( x ) => {
            const {fs} = require( 'fs' )

            console.log( "gubbmins", fs  )
            dialog.showMessageBox( { 
                type: "info", 
                message: "stuff" 
            })  
        }
    }
)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!