question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webview and @electron/remote

See original GitHub issue

Electron version: 15.3.1 @electron/remote version: 2.0.1

When adding a <webview /> that has a preload script that imports @electron/remote I get Error: @electron/remote is disabled for this WebContents..

electronRemoteMain.enable(window.webContents); is ran on the BrowserWindow that renders the webview and the wrapping React component is able to use @electron/remote, but the webview hasn’t been enabled.

Is there a way of enabling the remote module for a webview?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

5reactions
kl-nevermorecommented, Nov 25, 2021

This used to work in version 1.x with the { webPreferences: { enableRemoteModule: true } } setting added to the BrowserWindow. I found a solution

const mainWindow = new BrowserWindow(opts)
remoteMain.enable(mainWindow.webContents);
mainWindow.webContents.on('will-attach-webview', () => {
      const all = webContents.getAllWebContents();
      all.forEach((item) => {
        remoteMain.enable(item);
     });
});

1reaction
kl-nevermorecommented, Sep 23, 2022

replace remote is best solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

`<webview>` Tag | Electron
Use the webview tag to embed 'guest' content (such as web pages) in your Electron app. The guest content is contained within the...
Read more >
@electron/remote - npm
electron /remote` is an [Electron](https://electronjs.org) module that bridges JavaScript objects from the main process to the renderer ...
Read more >
Comunication between webview and main window without ...
Is there a way to communicate between the webview and the main window without enabling the remote module ? ... When this attribute...
Read more >
Anatomy of an Electron 4 application - TypeScript TV
1. main process. 1.1. Concerns · 2. renderer process. 2.1. Concerns; 2.2. Characteristics; 2.3. Example · 3. Inter-process communication (IPC) · 4. Webview...
Read more >
How to use the electron.remote.app function in electron - Snyk
_onLogoutNylasIdentity = async () => { await this.saveIdentity(null); // We need to relaunch the app to clear the webview session // and prevent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found