Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Loading Local HTML, | Electron.js Desktop App Development le | BraveProgrammer
  1. Courses
  2. /
  3. Electron.js Desktop App Development

Lesson 26 of 28

·javascript

Loading Local HTML, Remote URLs & Custom Protocols

8 mins

Course progress93%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `loadFile` loads a local HTML file relative to the app's directory.
  • `loadURL` can point to any HTTP(S) address but must be used with strict CSP.
  • Custom protocols (`protocol.registerFileProtocol`) let you treat bundled assets like files.

Loading Local HTML, Remote URLs & Custom Protocols

Local file – most common:

win.loadFile('src/index.html');

Remote URL – be careful with security (CSP, webSecurity):

win.loadURL('https://app.example.com');

Custom protocol – useful for bundlers (e.g., app://):

app.whenReady().then(() => {
  protocol.registerFileProtocol('app', (request, callback) => {
    const url = request.url.substr(6); // strip "app://"
    callback({ path: path.normalize(`${__dirname}/${url}`) });
  });
  win.loadURL('app://index.html');
});

When loading remote content, disable Node integration and enforce Content‑Security‑Policy headers.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Electron.js Desktop App DevelopmentBrowse activities
Previous lessonCreating BrowserWindows – Options & FeaturesContinue to lesson 27Menus, Application Menu & Tray IconsBack to Electron.js Desktop App Development curriculum