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

@cyca/electron-sirv

v0.1.3

Published

Static file serving for Electron apps

Downloads

526

Readme

@cyca/electron-sirv

Static file serving for Electron apps.

@cyca/electron-sirv registers a custom Electron protocol and serves files from your app directory using sirv-style static resolution.

It is inspired by electron-serve, but uses the newer electron.protocol handler APIs and keeps the static serving layer aligned with sirv.

Behavior Notes

This package keeps the Electron-facing API shape from electron-serve, but the static file resolution and serving behavior is based on sirv.

That means SPA fallback behavior follows sirv semantics:

  • extensionless unresolved routes like /settings can fall back to the SPA entry
  • unresolved file-like routes like /settings.html do not fall back
  • unresolved asset routes like /logo.png do not fall back

The file option is still supported at the Electron API layer, so you can load an entry file other than index.html.

When you pass a pathSegment to loadURL(), it is appended to the window URL without tacking it onto the HTML filename. That keeps the document base rooted correctly for relative assets, while sirv can still resolve the route back to the configured HTML entry file through SPA fallback.

Usage

import {app, BrowserWindow} from 'electron';
import {serve} from '@cyca/electron-sirv';

const loadURL = serve({directory: 'renderer'});

let mainWindow;

(async () => {
	await app.whenReady();

	mainWindow = new BrowserWindow();

	await loadURL(mainWindow);

	// Or optionally with a path segment and query string.
	await loadURL(mainWindow, '/settings?tab=profile');

// The above is equivalent to this:
await mainWindow.loadURL('app://-/settings?tab=profile');
	// The `-` is just the required hostname
})();

To load a different HTML entry file, set file:

const loadPopup = serve({directory: 'renderer', file: 'popup'});

await loadPopup(mainWindow);
// Loads `app://-/popup.html`

API

serve(options)

Creates a loadURL(window, pathSegment?) function for a BrowserWindow.

Important options:

  • directory: Root directory to serve from, relative to app.getAppPath()
  • file: Entry HTML file name without the .html extension. Defaults to index
  • single: Enables SPA fallback behavior using sirv semantics

Notes:

  • file: 'popup' makes loadURL(window) load app://-/popup.html
  • single: true falls back to the configured entry for unresolved extensionless routes
  • single: 'admin.html' uses admin.html as the SPA fallback target
  • pathSegment can include both the pathname suffix and query string

Request URL examples:

| file option | loadURL() call | Browser request URL | Resolved HTML file | | --- | --- | --- | --- | | index | loadURL(window) | app://-/ | index.html | | index | loadURL(window, '/settings') | app://-/settings | index.html via SPA fallback | | docs | loadURL(window) | app://-/docs.html | docs.html | | docs | loadURL(window, '/settings') | app://-/settings | docs.html via SPA fallback |