🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@app-config/electron

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@app-config/electron

Exposes app-config values to Electron render processes

2.9.0-beta.3
latest
Source
npm
Version published
Weekly downloads
50
-15.25%
Maintainers
2
Weekly downloads
 
Created
Source

App Config Electron

Easily inject app-config values into Electron renderer processes. An example project is provided here.

Usage

1. Install App Config and the Electron Package

yarn add @app-config/main @app-config/electron

Or, if you use NPM.

npm i @app-config/main @app-config/electron

2. Load your config with any options you need in the main Electron process before creating any windows

app.whenReady().then(() => {
  loadConfig().then(() => {
    const mainWindow = new BrowserWindow();

    mainWindow.loadFile('./index.html')
  });
});

3. Insert the App Config preload script into your BrowserWindow webPreferences

Pass your config and optionally any other BrowserWindow webPreferences you need to addAppConfigPreload.

app.whenReady().then(() => {
  loadConfig().then(() => {
    const mainWindow = new BrowserWindow({
      webPreferences: addAppConfigPreload(config),
    });

    mainWindow.loadFile('./index.html')
  });
});

4. Your App Config values are now available!

They can be found in window._appConfig or in config if using @app-config/main in your web page (when using @app-config/webpack with headerInjection or @app-config/vite with readGlobal). It's also available in config in the main Electron process.

Your app will need to be restarted to reflect any configuration changes.

Setting contextIsolation to true in the browserOptions of your BrowserWindow settings is required for this package to work. We set this for you, but if your app requres contextIsolation to be false using this package will break your app.

FAQs

Package last updated on 22 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts