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

@asterflow/plugin

v2.2.0

Published

The plugin-authoring system used to build AsterFlow plugins - a typed builder for context, config and lifecycle hooks.

Readme

@asterflow/plugin

license-info stars-info last-commit

bundle-size

The plugin-authoring system used to build AsterFlow plugins - a typed builder for context, config and lifecycle hooks.

📦 Installation

bun install @asterflow/plugin

✨ Features

  • Fluent builder: chain .config(), .decorate(), .derive(), .extends() and .on() off a single Plugin.create({ name }) call.
  • Typed config with defaults: .config() sets the plugin's default config and infers its shape.
  • Static and derived context: .decorate() injects a fixed value; .derive() computes a value from the config and context already built, lazily, when the plugin is registered.
  • Instance extensions: .extends() adds new properties/methods to the AsterFlow instance, computed from the app and the plugin's context.
  • Lifecycle hooks: .on() registers handlers for beforeInitialize, afterInitialize, onRequest and onResponse.
  • Type inference end-to-end: every chained call narrows a single Props type, so config, context and extensions stay typed without manual generics.

❓ How to Use

Build a plugin with Plugin.create, then chain the pieces it needs. This one adds a config option and exposes a method on the AsterFlow instance:

import { Plugin } from '@asterflow/plugin'

export const fsRoutingPlugin = Plugin.create({ name: 'fs-routing' })
  .config({ routes: [] as unknown[] })
  .extends((instance, context) => ({
    registerRoutes() {
      for (const route of context.routes) instance.controller(route)
    }
  }))
  .on('beforeInitialize', (instance, context) => instance.registerRoutes())

.decorate() and .derive() build up the plugin's context the same way - decorate for a static value, derive for one computed from config/context:

const withGreeting = Plugin.create({ name: 'greeting' })
  .decorate('appName', 'My App')
  .derive('greeting', (context) => `Hello, ${context.appName}!`)
  .on('afterInitialize', (_app, context) => console.log(context.greeting))

The finished plugin is registered on an app with app.use(fsRoutingPlugin, { routes: [...] }).

🔗 Related Packages

  • Depended on by asterflow - the core framework consumes plugin instances and their types to power app.use().
  • Depended on by @asterflow/multipart - built as a plugin with Plugin.create().
  • Depended on by @asterflow/fs - built as a plugin with Plugin.create().

📄 License

This project is licensed under the MIT License.