You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

web-electron

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-electron

CLI tool to convert web projects into Electron apps

npmnpm
Version
1.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

web-electron

A powerful, extensible CLI tool that converts web projects (React, Vue, Angular, Svelte) into cross-platform Electron applications with zero configuration.

🚀 Features

  • Multi-Framework Support: React, Vue.js, Angular, Svelte, and their meta-frameworks
  • Zero Configuration: Automatically detects project setup and generates appropriate Electron boilerplate
  • TypeScript Ready: Full TypeScript support with proper type generation
  • Modern Module Systems: Supports both ES Modules and CommonJS
  • Package Manager Agnostic: Works with npm, yarn, pnpm, and bun
  • Extensible Architecture: Plugin system for custom framework support
  • Smart Detection: Automatically identifies build systems, dev servers, and project structure

📦 Installation

npm install -g web-electron

🎯 Quick Start

Convert a Project

# Convert current directory
web-electron convert

# Convert specific project
web-electron convert ./my-react-app

# Convert with defaults (skip prompts)
web-electron convert --yes

# Convert without installing dependencies
web-electron convert --no-install

Validate a Project

# Validate current directory
web-electron validate

# Validate specific project
web-electron validate ./my-vue-app

Show Supported Frameworks

web-electron frameworks

🏗️ Architecture

Modular Framework System

The CLI uses a modular architecture where each framework is implemented as a separate adapter:

src/
├── core/                    # Core system
│   ├── BaseFramework.js     # Base class for all frameworks
│   ├── FrameworkRegistry.js # Framework registration and detection
│   ├── FrameworkFactory.js  # Framework instantiation
│   ├── ConfigManager.js     # Configuration management
│   ├── PluginManager.js     # Plugin system
│   └── IFramework.js        # Framework interface definition
├── frameworks/              # Framework adapters
│   ├── react/
│   │   └── ReactFramework.js
│   ├── vue/
│   │   └── VueFramework.js
│   ├── angular/
│   │   └── AngularFramework.js
│   └── svelte/
│       └── SvelteFramework.js
└── utils/                   # Utility modules
    ├── file-generator.js    # File generation using framework templates
    └── package-manager.js   # Package.json modification and dependency installation

Framework Adapter Pattern

Each framework implements the BaseFramework interface:

import { BaseFramework } from "../../core/BaseFramework.js";

export class MyFramework extends BaseFramework {
  static displayName = "My Framework";
  static description = "My awesome framework";
  static icon = "🎯";
  static supportedBuildSystems = ["vite", "webpack"];

  // Detection
  static canHandle(packageJson, projectDir) {
    /* ... */
  }
  static async detectConfig(projectDir) {
    /* ... */
  }

  // Configuration
  getBuildConfig() {
    /* ... */
  }
  getDevServerConfig() {
    /* ... */
  }

  // Template generation
  getMainTemplate() {
    /* ... */
  }
  getPreloadTemplate() {
    /* ... */
  }
  getHandlersTemplate() {
    /* ... */
  }
  getBuilderTemplate() {
    /* ... */
  }

  // Package.json modifications
  getScripts() {
    /* ... */
  }
  getPackageJsonModifications() {
    /* ... */
  }
  getDependencies() {
    /* ... */
  }
}

🔧 Supported Frameworks & Build Systems

Frontend Frameworks

  • ⚛️ React - JavaScript library for building user interfaces
  • 🖖 Vue.js - Progressive JavaScript framework
  • 🅰️ Angular - Platform for building mobile and desktop web apps
  • 🔥 Svelte - Cybernetically enhanced web apps

Build Systems & Meta-Frameworks

  • ⚡ Vite - Next generation frontend tooling
  • ⚛️ Create React App (CRA) - Set up a modern React app
  • 🚀 Next.js - React framework for production
  • 🏔️ Nuxt.js - Vue.js framework
  • 🅰️ Angular CLI - Command-line interface for Angular
  • 🔥 SvelteKit - Full-stack framework for Svelte
  • 📦 Webpack - Module bundler
  • 🎡 Rollup - Module bundler

Languages & Module Systems

  • 📄 JavaScript / 📘 TypeScript
  • 📦 CommonJS / 🆕 ES Modules

Package Managers

  • 📦 npm - Node Package Manager
  • 🧶 yarn - Fast, reliable package manager
  • 📦 pnpm - Fast, disk space efficient package manager
  • 🥟 bun - Fast all-in-one JavaScript runtime

🛠️ Development Scripts

After conversion, your project will have these new scripts:

# Start Electron in development mode
npm run electron-dev

# Build and package Electron app
npm run electron-build

# Build for distribution
npm run electron-dist

📘 TypeScript Support

web-electron provides seamless TypeScript support for Electron main processes:

Automatic TypeScript Detection

  • Detects TypeScript projects based on tsconfig.json presence or TypeScript dependencies
  • Generates TypeScript main process files (main.ts, preload.ts, handlers/*.ts)
  • Automatically installs TypeScript-related dependencies

TypeScript Runtime Integration

For TypeScript projects, the CLI automatically chooses the best runtime based on your project's module system:

# For ESM projects (type: "module"), the dev script uses:
electron --loader=tsx/esm ./electron/main.ts

# For CommonJS projects, the dev script uses:
electron -r ts-node/register ./electron/main.ts

# For JavaScript projects, it uses:
electron .

Why Different Runtimes?

  • tsx for ESM projects: tsx handles ES modules with TypeScript seamlessly
  • ts-node for CommonJS projects: ts-node provides reliable CommonJS + TypeScript execution
  • Automatic detection: The CLI detects your module system and chooses the appropriate runtime

Benefits

  • No compilation step needed - TypeScript files run directly in development
  • Module system aware - Uses the best runtime for ESM or CommonJS projects
  • Fast execution - tsx provides near-instant TypeScript execution for ESM projects
  • Reliable execution - ts-node provides stable TypeScript execution for CommonJS projects
  • Type safety - Full TypeScript support with proper type checking
  • Development experience - Hot reload works seamlessly with TypeScript

Generated Files

TypeScript projects get:

  • electron/main.ts - Main Electron process with TypeScript
  • electron/preload.ts - Preload script with TypeScript
  • electron/handlers/app.ts - IPC handlers with TypeScript
  • Proper type definitions for Electron APIs

🔌 Extensibility

Adding New Frameworks

  • Create a new framework adapter:
// src/frameworks/myframework/MyFramework.js
import { BaseFramework } from "../../core/BaseFramework.js";

export class MyFramework extends BaseFramework {
  // Implement required methods...
}
  • Register the framework:
// src/core/FrameworkRegistry.js
import { MyFramework } from "../frameworks/myframework/MyFramework.js";

export class FrameworkRegistry {
  static frameworks = [
    // ... existing frameworks
    MyFramework,
  ];
}

Plugin System

Create plugins to extend functionality:

import { PluginManager, HOOKS } from "./src/core/PluginManager.js";

const myPlugin = {
  name: "my-plugin",
  hooks: {
    [HOOKS.AFTER_FRAMEWORK_DETECTION]: async (data) => {
      // Modify framework detection result
      return data;
    },
  },
};

PluginManager.registerPlugin("my-plugin", myPlugin);

Configuration

Create a .web-electron.json file in your project:

{
  "frameworkPriority": ["react", "vue", "angular", "svelte"],
  "buildConfigs": {
    "react": {
      "buildDir": "build",
      "devPort": 3000
    }
  },
  "electron": {
    "version": "^28.0.0"
  }
}

📁 Generated Project Structure

After conversion, your project will have:

your-project/
├── electron/                    # Electron main process
│   ├── main.js (or .ts)        # Main process entry point
│   ├── preload.js (or .ts)     # Preload script for security
│   └── handlers/               # IPC handlers
│       └── app.js (or .ts)     # Example handlers
├── electron-builder.yml        # Electron Builder configuration
└── package.json                # Updated with Electron scripts and dependencies

🔒 Security

The generated Electron app follows security best practices:

  • Context Isolation: Enabled by default
  • Node Integration: Disabled in renderer
  • Preload Scripts: Used for secure IPC communication
  • Remote Module: Disabled

🐛 Troubleshooting

Common Issues

  • Framework not detected: Ensure your package.json has the framework listed in dependencies
  • Build failures: Check that your build script works independently first
  • Port conflicts: Modify the dev port in generated scripts if needed

Debug Mode

Run with verbose logging:

DEBUG=web-electron* web-electron convert

🤝 Contributing

  • Fork the repository
  • Create a feature branch
  • Add your framework adapter in src/frameworks/
  • Update the registry and factory
  • Add tests
  • Submit a pull request

Framework Adapter Checklist

  • Implement all required methods from BaseFramework
  • Add proper TypeScript/JavaScript detection
  • Support multiple build systems
  • Generate framework-specific templates
  • Add comprehensive error handling
  • Include examples and documentation

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

  • Electron team for the amazing framework
  • All frontend framework communities
  • Contributors and users of this tool

Keywords

electron

FAQs

Package last updated on 29 Jun 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