Set "checked" in menu from cookie in app


I have some settings that I want both in my main application and in the topbar menu. That leaves me that issue of syncing the settings.

In my React application, I simply save my settings to the cookie. So the question becomes, how do I access the application cookie when I create the topbar menu in the main.js file?

This is how a basic example of my topbar menu from my main.js file:

// Create menu
const menuArray = [
    label: 'Settings',
    submenu: [
        label: 'Sound',
        type: 'checkbox',
        checked: true, // Fetch saved cookie in app
        click: () => { 
          // Run function in app that changes saved cookie

// Set menu
const menu = Menu.buildFromTemplate(menuArray);

How would you access the cookie and how would you call the function in the application that changes the cookie?


Window have cookies, main.js does not, you need some different storage…


How do I save whether a menu item is checked or unchecked between sessions then? And can I access that stage from my main app?


You can use some module like electron-settings in main js, or store sessions in some database like NeDB, or json file trought file system, and you can access the data from the main.js


Hmm ok. Do you know of any examples out there of people having done the same? Seems like functionality that a lot of people would need?

Do you see any possibility of the React app and the Electron app being able to “share” that state?


You can use one database on both of them, so you are react developer and know nothing about javascript?


I’m a React developer who knows nothing about solving this particular problem. Do you wanna refer me to an example instead of insulting me?