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

@webhandle/initialize-webhandle-component

v1.0.4

Published

Boilerplate code for a module to add itself to a webhandle instance

Downloads

483

Readme

@webhandle/initialize-webhandle-component

Webhandle Components are a way to add services, templates, static files, middleware, or other code to a webhandle instance. What the component does, how it does it, and how it exposes that functionality is totally up to the component.

There are only three rules:

  1. A file will exist at the root of the package, initialize-webhandle-component.mjs, that will export a default async function taking a webhandle instance and options as parameters.
export default async function setup(webhandle, options) {
	// something here
}
  1. The function is safe to invoke multiple times on the same webhandle instance.

  2. The function returns an object which exposes any data or functionality that the component provides. This can be an empty object if there's no exposed functionality.

The code in this package has some ideas about what exposed functionality looks like and how to handle multiple invocations of the function. They are only suggestions and the code itself in this package only exists to prevent having to copy the same boilerplate over and over again.

Install

npm install @webhandle/initialize-webhandle-component

Creating a Component

The initialization file can be created for you by running

npx create-initialize-webhandle-component-file

This will create the file initiailze-webhandle-component.mjs in the current directory. Make sure to go in and change the component name and add the code needed to integrate your functionality.

Using a Component

  1. Install that component via npm like:
npm install @my/component
  1. Import and run the setup function like:
import setup from "@my/component/initialize-webhandle-component.mjs"
await setup(myWebhandleInstance, options)

Component Documentation

There's lots of things you'd want to document about the what your component does, but here are the things you probably should mention to help callers access those functions.

On the server side:

  1. The services exposed
  2. The events emitted
  3. The static content made available
  4. The templates made available

On the client side:

  1. The js modules supplied to client code.
  2. The URLs at which exposed functionality is available.