electron-is-dev
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

electron-is-dev

Check if Electron is running in development

Useful for enabling debug features only during development.

This package must be used from the Electron main process.

Install

npm install electron-is-dev

Requires Electron 28 or later.

Usage

import isDev from 'electron-is-dev';

if (isDev) {
	console.log('Running in development');
} else {
	console.log('Running in production');
}

You can force development mode by setting the ELECTRON_IS_DEV environment variable to 1.

FAQ

How is this different than app.isPackaged?

This package existed long before that property. The benefit of this package is that you can override the value using an environment variable.

How do I use this in the renderer process?

You can use contextBridge in the preload script to manually expose the variable:

import {contextBridge} from 'electron';
import isDev from 'electron-is-dev';

contextBridge.exposeInMainWorld('isDev', isDev);

You can then access it in globalThis from the renderer process:

console.log(globalThis.isDev);

Related

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 3.0.1
    2,981
    • latest

Version History

Package Sidebar

Install

npm i electron-is-dev

Weekly Downloads

96,925

Version

3.0.1

License

MIT

Unpacked Size

4.3 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus