From 6ee299c9eec451d1efcab4be09c3b3e4a028d2c9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:23:42 -0500 Subject: [PATCH] docs: recommend calling renderer process modules from preload script (#48462) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Niklas Wenzel --- docs/api/clipboard.md | 6 ++++++ docs/api/crash-reporter.md | 6 ++++++ docs/api/ipc-renderer.md | 6 ++++++ docs/api/native-image.md | 6 ++++++ docs/api/web-frame.md | 6 ++++++ docs/api/web-utils.md | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index 275a7afe6210..a6e6da7592ea 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -4,6 +4,12 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) (non-sandboxed only) +> [!IMPORTANT] +> If you want to call this API from a renderer process with context isolation enabled, +> place the API call in your preload script and +> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the +> [`contextBridge`](context-bridge.md) API. + On Linux, there is also a `selection` clipboard. To manipulate it you need to pass `selection` to each method: diff --git a/docs/api/crash-reporter.md b/docs/api/crash-reporter.md index d00dad544f7b..a269750e7049 100644 --- a/docs/api/crash-reporter.md +++ b/docs/api/crash-reporter.md @@ -4,6 +4,12 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) +> [!IMPORTANT] +> If you want to call this API from a renderer process with context isolation enabled, +> place the API call in your preload script and +> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the +> [`contextBridge`](context-bridge.md) API. + The following is an example of setting up Electron to automatically submit crash reports to a remote server: diff --git a/docs/api/ipc-renderer.md b/docs/api/ipc-renderer.md index 53722a414bbe..307ac8bf0126 100644 --- a/docs/api/ipc-renderer.md +++ b/docs/api/ipc-renderer.md @@ -20,6 +20,12 @@ changes: Process: [Renderer](../glossary.md#renderer-process) +> [!IMPORTANT] +> If you want to call this API from a renderer process with context isolation enabled, +> place the API call in your preload script and +> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the +> [`contextBridge`](context-bridge.md) API. + The `ipcRenderer` module is an [EventEmitter][event-emitter]. It provides a few methods so you can send synchronous and asynchronous messages from the render process (web page) to the main process. You can also receive replies from the diff --git a/docs/api/native-image.md b/docs/api/native-image.md index 68ecbbe1ad1d..61b3c5ab3173 100644 --- a/docs/api/native-image.md +++ b/docs/api/native-image.md @@ -4,6 +4,12 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) +> [!IMPORTANT] +> If you want to call this API from a renderer process with context isolation enabled, +> place the API call in your preload script and +> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the +> [`contextBridge`](context-bridge.md) API. + The `nativeImage` module provides a unified interface for manipulating system images. These can be handy if you want to provide multiple scaled versions of the same icon or take advantage of macOS [template images][template-image]. diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index 2bd42fe3cf9f..2681df864a50 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -4,6 +4,12 @@ Process: [Renderer](../glossary.md#renderer-process) +> [!IMPORTANT] +> If you want to call this API from a renderer process with context isolation enabled, +> place the API call in your preload script and +> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the +> [`contextBridge`](context-bridge.md) API. + `webFrame` export of the Electron module is an instance of the `WebFrame` class representing the current frame. Sub-frames can be retrieved by certain properties and methods (e.g. `webFrame.firstChild`). diff --git a/docs/api/web-utils.md b/docs/api/web-utils.md index f4518149c350..f1d04fcc9887 100644 --- a/docs/api/web-utils.md +++ b/docs/api/web-utils.md @@ -4,6 +4,12 @@ Process: [Renderer](../glossary.md#renderer-process) +> [!IMPORTANT] +> If you want to call this API from a renderer process with context isolation enabled, +> place the API call in your preload script and +> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the +> [`contextBridge`](context-bridge.md) API. + ## Methods The `webUtils` module has the following methods: