Socket
Socket
Sign inDemoInstall

@app-config/electron

Package Overview
Dependencies
263
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @app-config/electron

Exposes app-config values to Electron render processes


Version published
Maintainers
2
Created

Readme

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

Last updated on 08 Jun 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc