npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

electron-quick-ejs

v1.0.2

Published

A modern, secure, and zero-configuration EJS renderer for Electron.

Readme

🚀 electron-quick-ejs

A modern, secure, and zero-configuration EJS Renderer for Electron applications. Built for Electron 40+ and EJS v4, utilizing native protocol.handle for maximum performance and security.

Why use this? Unlike older libraries, this uses Electron's native Custom Protocols (app://) instead of insecure file access or remote modules. It also includes Smart Path Repair to automatically fix broken asset links.

npm version License: MIT

✨ Features

  • 🔒 Secure: Uses native protocol.handle with Path Traversal Protection (prevents access outside views folder).
  • Fast: Built-in caching headers for static assets (CSS/Images/JS).
  • 🧠 Smart Path Resolution: Automatically fixes common browser URL issues (e.g., resolving index/assets/style.css).
  • 📂 Asset Support: Seamlessly loads .css, .png, .js, .svg, and more.
  • 🛠 TypeScript Ready: Includes type definitions (index.d.ts) out of the box.

📦 Installation

npm install electron-quick-ejs

🚀 Quick Start

1. Setup in main.js (Main Process)

const { app, BrowserWindow } = require('electron');
const path = require('path');
const ElectronQuickEjs = require('electron-quick-ejs');

// 1. Initialize the renderer
const ejs = new ElectronQuickEjs({
  // Point to your views folder (Required)
  viewsDir: path.join(__dirname, 'views'), 
  
  // (Optional) Global data accessible in all templates
  data: { 
    appName: 'My Awesome App',
    year: 2026
  }
});

let mainWindow;

app.whenReady().then(() => {
  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true, 
      contextIsolation: false
    }
  });

  // 2. Load your file using the 'app://' protocol
  // No need for .ejs extension. 'index' maps to 'views/index.ejs'
  mainWindow.loadURL('app://index');
});

2. Create views/index.ejs (Frontend)

⚠️ Important: Always use absolute paths (starting with /) for your assets to ensure they load correctly.

<!DOCTYPE html>
<html>
<head>
    <title><%= appName %></title>
    <link rel="stylesheet" href="/assets/style.css">
</head>
<body style="background-color: #1a1a1a; color: white;">

    <h1>Welcome to <%= appName %></h1>
    <p>Current Year: <%= year %></p>
    
    <img src="/assets/logo.png" alt="Logo" width="150">

    <script src="/assets/script.js"></script>
</body>
</html>

📂 Recommended Folder Structure

To ensure the security logic works correctly, keep all your assets inside the views directory.

my-electron-app/
├── main.js
├── package.json
└── views/              <-- Pass this path to 'viewsDir'
    ├── index.ejs
    ├── about.ejs
    └── assets/         <-- Keep CSS/Images here
        ├── style.css
        ├── script.js
        └── logo.png

📝 API Options

new ElectronQuickEjs(options)

| Option | Type | Required | Description | | --- | --- | --- | --- | | viewsDir | string | Yes | Absolute path to your EJS templates folder. | | data | object | No | Global variables available in all templates (e.g. App Name). |

🛡️ Security & Performance

  • Sandboxing: The renderer prevents access to files outside your viewsDir. E.g., app://../../password.txt will return Access Denied.
  • Caching: EJS templates are always re-rendered (no-cache) for hot-reloading data, while static assets (images, css) are cached for 1 year for production-level performance.

🤝 License

MIT License. Free for commercial and personal use.