Electron NodeJS files #32
-
First off, this boilerplate is perfect! I just can't seem to find where I put my scripts for sharing data between NodeJS and my React UI. I rather keep the NodeIntegration on false and use something like the electron docs say, a preload.js kind of method. I wonder if the bridge between Node and React has maybe already been made by the boilerplate but I cannot find it if that's the case. I simply need to "require()" some NodeJs modules and securely expose the output from those script to my React UI. I don't see anything like this in the Readme either so please help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @PixelForm
Your welcome!
To share data between We used the same api in this project for the custom window frame/titlebar events handling. // misc/window/windowPreload.ts
import { contextBridge } from 'electron';
import titlebarContext from './titlebarContext';
contextBridge.exposeInMainWorld('electron_window', {
titlebar: titlebarContext,
}); Exposed api by context-bridge will be available in All window frame/titlebar specific events are defined using IPC api, for example : misc/window/titlebarIPC.ts // Exposing events in renderer process (browser) for window titlebar buttons, menus etc.
misc/window/titlebarIPC.ts // Defining callbacks for main process to handle all requested window events of renderer process. |
Beta Was this translation helpful? Give feedback.
Hello @PixelForm
Your welcome!
To share data between
main
andrenderer
process you can use electron's contextBridge api.We used the same api in this project for the custom window frame/tit…