Skip to content

Commit

Permalink
chore: update ref to docs (🤖)
Browse files Browse the repository at this point in the history
  • Loading branch information
1 parent 815866d commit eb95898
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/latest/api/context-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ has been included below for completeness:

If the type you care about is not in the above table, it is probably not supported.

### Exposing ipcRenderer

Attempting to send the entire `ipcRenderer` module as an object over the `contextBridge` will result in
an empty object on the receiving side of the bridge. Sending over `ipcRenderer` in full can let any
code send any message, which is a security footgun. To interact through `ipcRenderer`, provide a safe wrapper
like below:

```js
// Preload (Isolated World)
contextBridge.exposeInMainWorld('electron', {
onMyEventName: (callback) => ipcRenderer.on('MyEventName', (e, ...args) => callback(args))
})
```

```js @ts-nocheck
// Renderer (Main World)
window.electron.onMyEventName(data => { /* ... */ })
```

### Exposing Node Global Symbols

The `contextBridge` can be used by the preload script to give your renderer access to Node APIs.
Expand Down

0 comments on commit eb95898

Please sign in to comment.