Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuxt-electron

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-electron

Nuxt Integration with Electron

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
467
increased by5.42%
Maintainers
1
Weekly downloads
 
Created
Source

Nuxt Electron

npm version npm downloads License

Integrate Nuxt and Electron

Features

  • 🚀 High-performance (Not Bundle, based on esbuild)
  • 📦 Out of the box
  • 🔥 Hot restart

Quick Setup

  1. Add the following dependency to your project
# Using pnpm
pnpm add -D nuxt-electron vite-electron-plugin vite-plugin-electron-renderer electron electron-builder

# Using yarn
yarn add --dev nuxt-electron vite-electron-plugin vite-plugin-electron-renderer electron electron-builder

# Using npm
npm install --save-dev nuxt-electron vite-electron-plugin vite-plugin-electron-renderer electron electron-builder
  1. Add nuxt-electron to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-electron',
  ],
})
  1. Create the electron/main.ts file and type the following code
import { app, BrowserWindow } from 'electron'

app.whenReady().then(() => {
  new BrowserWindow().loadURL(process.env.VITE_DEV_SERVER_URL)
})
  1. Add the main entry to package.json
{
+ "main": "dist-electron/main.js"
}

That's it! You can now use Electron in your Nuxt app ✨

Electron Options

This is based on the vite-electron-plugin, see the Documents for more detailed options

Here is the default electron options

export default defineNuxtConfig({
  modules: [
    'nuxt-electron',
  ],
  electron: {
    include: ['electron'],
    outDir: 'dist-electron',
  },
})

Use Node.js in Renderer process

export default defineNuxtConfig({
  modules: [
    'nuxt-electron',
  ],
  electron: {
    /**
     * @see https://github.com/electron-vite/vite-plugin-electron-renderer
     */
    renderer: {},
  },
})

Recommend Structure

Let's use the official nuxt-starter-v3 template as an example

+ ├─┬ electron
+ │ └── main.ts
  ├─┬ public
  │ └── favicon.ico
  ├── .gitignore
  ├── .npmrc
  ├── index.html
  ├── app.vue
  ├── nuxt.config.ts
  ├── package.json
  ├── README.md
  └── tsconfig.json

Examples

Notes

By default, we force the App to run in SPA mode since we don't need SSR for desktop apps

Keywords

FAQs

Package last updated on 12 Mar 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc