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

@datafn/extfn

v0.1.0

Published

DataFn integration plugin and proxy client surface for extfn consumers

Readme

@datafn/extfn

@datafn/extfn is the DataFn integration layer for extfn.

It keeps DataFn authority in the extension background context and gives popup, options, sidepanel, and content code a proxy client surface that stays aligned with the public @datafn/client API.

What this package owns

  • background authority setup
  • background request routing for DataFn RPC methods
  • cross-context proxy client creation
  • subscription fanout and cleanup for extension contexts

It does not move DataFn semantics into extfn core.

Public surface

The package exports:

  • createDatafnExtfnAuthority(...)
  • createDatafnExtfnProxyClient(...)
  • createBrowserDatafnExtfnBridge(...)
  • datafnExtfn(...)
  • createDatafnExtfnRoutes(...)

Options

DatafnExtfnOptions is based on the current public DatafnClientConfig shape.

Supported keys:

  • schema
  • clientId
  • namespace
  • sync
  • storage
  • plugins
  • searchProvider
  • requestTimeoutMs

Not supported:

  • authContext

If you need auth/session behavior, keep that in consumer code or another package-owned layer and pass DataFn the resulting configuration or storage behavior explicitly.

Background authority

Create the authority in background code only.

import { createDatafnExtfnAuthority } from "@datafn/extfn";
import { demoNamespace, demoSchema } from "./demoSchema.js";

const authority = createDatafnExtfnAuthority(
  {
    schema: demoSchema,
    clientId: "authority:demo",
    namespace: demoNamespace,
  },
  {
    address: {
      context: "background",
    },
  },
);

authority.attachBrowserRuntimeBridge();

The authority:

  • rejects non-background startup
  • reuses @datafn/client storage adapters
  • owns subscription lifecycle
  • speaks extfn-compatible request/response/event envelopes to extension contexts

Popup, options, sidepanel, and content clients

Create a proxy client in any non-background context.

import { createDatafnExtfnProxyClient } from "@datafn/extfn";

const client = createDatafnExtfnProxyClient({
  schema: demoSchema,
  clientId: "popup:demo",
  namespace: demoNamespace,
});

const notes = await client.query({
  resource: "note",
  version: 1,
  select: ["id", "title"],
});

You can also pass explicit runtime options:

const client = createDatafnExtfnProxyClient(
  {
    schema: demoSchema,
    clientId: "content:demo",
    namespace: demoNamespace,
  },
  {
    address: {
      context: "content",
      contentScriptId: "highlights",
      tabId: 12,
    },
  },
);

Using the plugin helper

datafnExtfn(...) returns a runtime plugin plus convenience accessors.

Use it when your package wants to bundle:

  • a stable plugin id
  • background route registration
  • a reusable proxy-client factory

Keep in mind that background authority startup is still package-owned logic.

Example in this repo

See:

  • extfn/examples/svelte-datafn-demo/extfn.config.ts
  • extfn/examples/svelte-datafn-demo/src/background/index.ts
  • extfn/examples/svelte-datafn-demo/src/demoClient.ts

Validation from repo root

npm run test -- --filter=@datafn/extfn
npm run build -- --filter=svelte-datafn-demo
npm exec extfn scan -- --config extfn/examples/svelte-datafn-demo/extfn.config.ts