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

@nexus-js/chrome

v0.1.1

Published

Chrome extension adapter for Nexus framework

Readme

@nexus/chrome-adapter

Chrome extension adapter for the Nexus framework, providing seamless cross-context communication for Chrome extensions.

Installation

npm install @nexus/chrome-adapter @nexus/core

Quick Start

Background Script

import {
  usingBackgroundScript,
  nexus,
  Expose,
  Token,
} from "@nexus/chrome-adapter";

// Define service interface and token
interface IBackgroundService {
  getSettings(): Promise<Settings>;
  saveSettings(settings: Settings): Promise<void>;
}

const BackgroundServiceToken = new Token<IBackgroundService>(
  "background-service"
);

// Configure Nexus for background context
usingBackgroundScript();

// Expose service
@Expose(BackgroundServiceToken)
class BackgroundService implements IBackgroundService {
  async getSettings() {
    return await chrome.storage.sync.get("settings");
  }

  async saveSettings(settings: Settings) {
    await chrome.storage.sync.set({ settings });
  }
}

Content Script

import { usingContentScript, nexus } from "@nexus/chrome-adapter";
import { BackgroundServiceToken } from "./shared/tokens";

// Configure Nexus for content script context
usingContentScript();

// Use background service
async function main() {
  const backgroundService = await nexus.create(BackgroundServiceToken, {
    target: { descriptor: { context: "background" } },
  });

  const settings = await backgroundService.getSettings();
  console.log("Settings:", settings);
}

main();

Popup

import { usingPopup, nexus } from "@nexus/chrome-adapter";
import { BackgroundServiceToken } from "./shared/tokens";

// Configure Nexus for popup context
async function initPopup() {
  await usingPopup();

  const backgroundService = await nexus.create(BackgroundServiceToken, {
    target: { descriptor: { context: "background" } },
  });

  // Use the service
  const settings = await backgroundService.getSettings();
  // Update UI...
}

initPopup();

Features

  • Type-safe communication between all Chrome extension contexts
  • Automatic connection management with retry and reconnection
  • Pre-configured matchers for common scenarios
  • Zero-configuration setup for standard use cases
  • Full TypeScript support with discriminated union types

API Reference

Factory Functions

  • usingBackgroundScript() - Configure for background script/service worker
  • usingContentScript() - Configure for content script (with automatic visibility tracking)
  • usingPopup() - Configure for popup (async, gets current tab)
  • usingOptionsPage() - Configure for options page
  • usingDevToolsPage() - Configure for devtools page
  • usingOffscreenDocument(reason) - Configure for offscreen document

Pre-defined Matchers

  • any-content-script - Match any content script
  • any-popup - Match any popup
  • active-content-script - Match active content scripts
  • background - Match background script

Types

  • ChromeUserMeta - Discriminated union for all Chrome contexts
  • ChromePlatformMeta - Chrome-specific platform metadata
  • Context-specific types: BackgroundMeta, ContentScriptMeta, etc.

Advanced Usage

Custom Matchers

import { ChromeMatchers } from "@nexus/chrome-adapter";

// Use built-in matchers
const githubContentScripts = await nexus.createMulticast(ServiceToken, {
  target: { matcher: ChromeMatchers.contentScriptByUrl("github.com") },
});

// Custom matcher
const customMatcher = (identity: ChromeUserMeta) =>
  identity.context === "content-script" &&
  identity.url.includes("special-page");

Dynamic Metadata Updates

// Content script automatically tracks visibility changes
// Manual updates are also supported:
nexus.updateIdentity({
  url: window.location.href, // Update URL for SPA navigation
  isActive: true,
});

New Context Support

// Options page
import { usingOptionsPage } from "@nexus/chrome-adapter";
usingOptionsPage();

// DevTools page
import { usingDevToolsPage } from "@nexus/chrome-adapter";
usingDevToolsPage();

// Offscreen document
import { usingOffscreenDocument } from "@nexus/chrome-adapter";
usingOffscreenDocument("audio-processing");

License

MIT