Code Monkey home page Code Monkey logo

nuxt-electron's Introduction

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 electron electron-builder

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

# Using npm
npm install --save-dev nuxt-electron vite-electron-plugin 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',
  },
})

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

Notes

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

nuxt-electron's People

Contributors

atinux avatar caoxiemeihao avatar gurvancampion avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.