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

@torpor/adapter-electron

v1.1.3

Published

A @torpor/build adapter for building desktop apps with Electron

Downloads

638

Readme

torpor/adapter-electron

A @torpor/build adapter for building desktop apps with Electron.

🚧 WARNING: WORK IN PROGRESS 🚧

Installation

Install the adapter and Electron using npm (or your preferred package manager):

npm install @torpor/adapter-electron
npm install -D electron

Then use the adapter in your site.config:

import { electron } from "@torpor/adapter-electron";
import { Site } from "@torpor/build";

const site: Site = new Site();
site.adapter = electron();

Commands

  • tb --dev builds the site and opens an Electron window against the Vite dev server, with HMR. The dev server is still available in the browser.
  • tb --build writes the desktop app to dist/electron.
  • tb --preview builds and launches the built app.

How it works

The generated app runs the site's server in the Electron main process on Node, and serves it over a loopback HTTP server (127.0.0.1), which the BrowserWindow loads. Because requests are real HTTP requests, cookies, sessions, flash messages and redirects behave exactly as they do with @torpor/adapter-node -- and Chromium's session cookie store persists them for you across launches (see Sessions below).

dist/electron contains:

  • main.mjs -- the Electron main process (starts the server, opens the window)
  • preload.cjs -- a context-isolated preload
  • electron.json -- the adapter options (host, port, partition, window)
  • package.json -- a minimal Electron app manifest

Sessions and auth

The adapter uses a persistent session partition (persist:torpor by default), so Torpor's signed session cookie survives restarts with no extra work. Cookies are scoped to the host, not the port, so this holds even though the default port is ephemeral.

For a "remember me" token that outlives the session, use Electron's safeStorage to encrypt it with the OS keychain (macOS Keychain, Windows DPAPI, Linux Secret Service) and write it under app.getPath("userData"). Never store passwords or tokens in localStorage or the renderer.

Options

site.adapter = electron({
	partition: "persist:torpor", // session partition (cookies/web storage)
	host: "127.0.0.1", // loopback host for the server
	port: 0, // 0 = ephemeral; pin a port to keep web storage stable
	window: { width: 1280, height: 800, title: "Flub" },
	dev: true, // set false to skip the desktop window in dev
});

Cookies persist across launches regardless of the port. Web storage (localStorage, IndexedDB) is origin-scoped, so pin port if the app relies on it staying put.

Packaging

The emitted dist/electron app is a normal Electron app; package it with electron-builder or Electron Forge by pointing the app directory at dist/electron. Include the site's node_modules (or add the emitted app's runtime dependencies to the builder config) so @torpor/adapter-electron and @torpor/build resolve. With pnpm, a hoisted node-linker is easiest.