Electron JS, Vite & Better SQLite: Complete Tutorial Build a Desktop App From Scratch to Installer
Piko Can Fly
@pikocanflyAbout
I like making things easier.
Latest Posts
Video Description
In this full course, we build a production-ready Desktop Application using Electron JS, Vite, and SQLite (better-sqlite3). You will learn how to create a local database app with full CRUD capabilities (Create, Read, Update, Delete) and handle IPC (Inter-Process Communication) securely. By the end of this tutorial, you won’t just have a working app; you will know how to solve common build errors, handle native Node.js dependencies, and package your project into a professional Windows Installer (.exe) to share with friends. 📌 What we cover in this tutorial: - Project Setup: Scaffolding an app with Electron Forge and the Vite template. - Database Logic: Using better-sqlite3 to save, read, and delete tasks locally. - IPC Bridge: Connecting the Front End (UI) to the Back End (Database) securely. - Real-world Coding: Debugging common errors, handling version mismatches, and configuring Vite for native modules. Distribution: How to build and package your app into an installable file. 🛠️ Tech Stack: - Node.js - Electron / Electron Forge - SQLite (better-sqlite3) - HTML/CSS/JavaScript 🕛 Timestamps: 00:00 - Intro: Building a Local Desktop App (Electron JS + SQLite Database) 01:21 - Project Setup: Electron Forge, Vite Template & Boilerplate 02:53 - Installing Native Dependencies (better-sqlite3) 03:23 - Error Fix: node-gyp rebuild failed & V8 Deprecation 04:43 - Skip to here; if you do not get an error 05:15 - Browser Window Config: "Always on Top" & Dimensions 05:50 - Frontend UI: HTML Structure for To-Do App 08:04 - File System: Accessing userData Path & Persistent Storage 09:21 - Database Setup: Connecting SQLite & Enabling WAL Performance Mode 10:19 - SQL Schema: Creating Tables with db.exec 11:16 - SQL Data Types: Primary Key, Auto Increment, Integer 12:16 - Main Process: Initializing Database on App Ready 13:25 - Vite Build Error: "Could not dynamically require" (Rollup Issue) 13:43 - Vite Config Fix: Externalizing Native Modules (better-sqlite3) 14:32 - Debugging: Viewing Data with DB Browser for SQLite 15:26 - CRUD Create: SQL Insert Statement & Preventing SQL Injection 16:58 - CRUD Delete: SQL Delete Statement & info.changes 17:36 - CRUD Update: SQL Update Statement (Mark Complete) 18:27 - CRUD Read: SQL Select Query (Get All Tasks) 19:28 - Architecture: IPC (Inter-Process Communication) Explained 20:02 - Backend API: ipcMain.handle & Asynchronous Handlers 24:04 - Cleanup: Closing Database Connection on App Quit 25:21 - Registering IPC Listeners in Main.js 25:49 - Security: Preload Scripts & Context Isolation 26:13 - Context Bridge: Exposing Safe APIs to Frontend 27:27 - Frontend API: ipcRenderer.invoke & Promises 29:38 - Renderer Logic: DOM Manipulation & Event Listeners 30:33 - Connecting UI to DB: Handling "Add Task" Events 32:42 - Rendering Data: Fetching & Displaying List Items 36:12 - Checkbox Logic: Boolean Conversion & State Management 38:26 - Delete Logic: Removing Items from UI & DB 41:41 - UX State Management: Refreshing the UI after Updates 43:25 - Final Polish: Disabling DevTools 43:34 - Menu Bar: Removing Default Electron Menu 45:03 - Distribution: Building the App (npm run make) 46:08 - Build Error Fix: "Cannot find module" (Native Bindings/ASAR) 48:11 - Forge Config: Fixing Native Dependencies in Production 48:52 - Testing the Portable Executable (.exe) 49:44 - Testing the Windows Installer (Setup.exe) 50:09 - Final Demo: Persistence & Desktop Shortcut #ElectronJS #Javascript #SQLite #NodeJS
Upgrade Your Everyday
AI-recommended products based on this video

Amazon Echo Show 8 (newest model), With Spatial Audio, Smart Home Hub, and Alexa, Charcoal

Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, with Active Noise Cancellation, Adaptive Audio, Transparency Mode, Personalized Spatial Audio, USB-C Charging Case, Wireless Charging, H2 Chip

Wireless Earbuds, Bluetooth 5.4 Headphones, True Wireless Stereo Earphones with IPX7 Waterproof, Noise Cancelling Mic, Fast Charging and Comfort Fit Ear Buds for Sports/Workouts - Black

Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, Personalized Spatial Audio, Sweat and Water Resistant, USB-C Charging Case, H2 Chip, Up to 30 Hours of Battery Life, Effortless Setup for iPhone

Apple AirPods Pro 2 Wireless Earbuds, Active Noise Cancellation, Hearing Aid Feature, Bluetooth Headphones, Transparency, Personalized Spatial Audio, High-Fidelity Sound, H2 Chip, USB-C Charging

Smart Watch for Men/Women, 1.95" AMOLED Fitness Tracker Watches with Bluetooth Calls/Flashlight/100+ Sport Modes Heart Rate/Sleep Monitor Ultra Lightweight Ultrathin Design

Smart Watch for Men Women (Answer/Make Call), 1.96" HD Smartwatch Fitness Activity Tracker, 110+ Sports IP68 Waterproof, Heart Rate/Sleep Monitor/Pedometer/Calories, Fitness Watch for Android iOS
![Apple Watch Series 10 [GPS 46mm case] Smartwatch with Rose Gold Aluminium Case with Light Blush Sport Band - M/L. Fitness Tracker, ECG App, Always-On Retina Display, Water Resistant](https://m.media-amazon.com/images/I/61nNNMI1cFL._AC_UL960_FMwebp_QL65_.jpg)
Apple Watch Series 10 [GPS 46mm case] Smartwatch with Rose Gold Aluminium Case with Light Blush Sport Band - M/L. Fitness Tracker, ECG App, Always-On Retina Display, Water Resistant
![Apple Watch Series 10 [GPS 42mm case] Smartwatch with Jet Black Aluminium Case with Black Sport Band - S/M. Fitness Tracker, ECG App, Always-On Retina Display, Water Resistant](https://m.media-amazon.com/images/I/6105jZyXyPL._AC_UL960_FMwebp_QL65_.jpg)
Apple Watch Series 10 [GPS 42mm case] Smartwatch with Jet Black Aluminium Case with Black Sport Band - S/M. Fitness Tracker, ECG App, Always-On Retina Display, Water Resistant

NOCO Boost GB40: 1000A UltraSafe Jump Starter – 12V Lithium Battery Booster Pack, Portable Jump Box, Power Bank & Jumper Cables - for 6.0L Gas and 3.0L Diesel Engines

UGREEN Nexode Power Bank 20000mAh 130W Portable Charger 72Wh PD Fast Charging 3-Port USB C Battery Pack with TFT Smart Display for MacBook/iPad/iPhone 16/Samsung S24 and More

ANKER 737 Power Bank, 24,000mAh 3-Port Laptop Portable Charger with 140W Fast Charging, Smart Display, for Outdoor Work, Compatible with iPhone 16/15/14 Series, Vision Pro, Samsung, MacBook, and More

VOLTME Portable Charger, Slim 10000mAh 5V/3A Power Bank, USB C in&Out High-Speed Charging Battery Pack, Travel Essentials Dual Output Compatible with iPhone 16 15 14 13 12 Samsung Google iPad etc

Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, with Active Noise Cancellation, Adaptive Audio, Transparency Mode, Personalized Spatial Audio, USB-C Charging Case, Wireless Charging, H2 Chip

Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, Personalized Spatial Audio, Sweat and Water Resistant, USB-C Charging Case, H2 Chip, Up to 30 Hours of Battery Life, Effortless Setup for iPhone

Apple AirPods Pro 2 Wireless Earbuds, Active Noise Cancellation, Hearing Aid Feature, Bluetooth Headphones, Transparency, Personalized Spatial Audio, High-Fidelity Sound, H2 Chip, USB-C Charging

Bose QuietComfort Bluetooth Headphones, Wireless Headphones with Active Over Ear Noise Cancelling and Mic, Deep Bass, Up to 24 Hours of Playtime, White Smoke

Barnyard Designs Indoor Herb Garden Planter Set with Tray, Metal Windowsill Plant Pots with Drainage for Outdoor or Indoor Plants, Set/3 (Black)

Eye Contact Web Camera for Desktop Computer – 1080P USB Camera with Microphone & Stand, Center Cam for Laptop or Desktop, Manual Focus, Plug & Play for macOS & Windows(Black)
![PEHAEL 3+3Pack for iPhone 17 Pro Max Privacy Screen Protector with Camera Lens Protector Full Coverage Anti-Spy Tempered Glass Film 9H Hardness Easy Installation Bubble Free [6.9 inch]](https://m.media-amazon.com/images/I/61PnVkv6KKL._AC_UL960_FMwebp_QL65_.jpg)
PEHAEL 3+3Pack for iPhone 17 Pro Max Privacy Screen Protector with Camera Lens Protector Full Coverage Anti-Spy Tempered Glass Film 9H Hardness Easy Installation Bubble Free [6.9 inch]
![Ailun 3 Pack Screen Protector for iPhone 16 Pro Max [6.9 inch] + 3 Pack Camera Lens Protector with Installation Frame,Sensor Protection,Dynamic Island Compatible,Case Friendly Tempered Glass Film](https://m.media-amazon.com/images/I/815keamN-BL._AC_UL960_FMwebp_QL65_.jpg)
Ailun 3 Pack Screen Protector for iPhone 16 Pro Max [6.9 inch] + 3 Pack Camera Lens Protector with Installation Frame,Sensor Protection,Dynamic Island Compatible,Case Friendly Tempered Glass Film

