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

@web-widget/schema

v1.70.1

Published

Web Widget and Web Router module format standard definitions

Readme

Module Format Schema

A technology-agnostic module format standard that defines the structure and types for web application modules. This schema provides a foundation for building modular web applications with clear separation of concerns and consistent interfaces.

Overview

This package defines TypeScript type definitions for a standardized module format that enables:

  • Route Modules: Handle HTTP requests and render pages
  • Widget Modules: Reusable components that work on both server and client
  • Action Modules: Server-side functions callable from the client
  • Middleware Modules: Request processing and context modification
  • HTTP Types: Standard HTTP request/response handling
  • Metadata Types: HTML document metadata management
  • Rendering Types: Server-side and client-side rendering interfaces

Module Types

Route Modules

Route modules handle HTTP requests and define page endpoints. They can contain components, handlers, metadata, and rendering logic.

📁 Type Definitions: types/route.d.ts

interface RouteModule {
  config?: RouteConfig;
  default?: RouteComponent;
  fallback?: RouteFallbackComponent;
  handler?: RouteHandler | RouteHandlers;
  meta?: Meta;
  render?: ServerRender;
}

Key Features:

  • HTTP method handlers for different request types
  • Server-side rendering with streaming support
  • Error handling with fallback components
  • Metadata management for HTML head elements
  • Type-safe context with request parameters and state

Widget Modules

Widget modules are reusable components that can be embedded in different contexts. They support both server-side and client-side rendering.

📁 Type Definitions: types/widget.d.ts

type WidgetModule = ServerWidgetModule | ClientWidgetModule;

interface ServerWidgetModule {
  default?: unknown;
  meta?: Meta;
  render?: ServerRender;
}

interface ClientWidgetModule {
  default?: unknown;
  meta?: Meta;
  render?: ClientRender;
}

Key Features:

  • Isomorphic components that work on server and client
  • Progressive hydration support
  • Lifecycle management for client-side rendering
  • Metadata integration for dynamic head elements

Action Modules

Action modules contain server-side functions that can be called from the client to perform operations.

📁 Type Definitions: types/action.d.ts

interface ActionModule {
  [method: string]: ActionHandler;
}

interface ActionHandler<A = SerializableValue, T = SerializableValue> {
  (...args: A[]): Promise<T>;
}

Key Features:

  • Type-safe serializable arguments and return values
  • Promise-based async operations
  • Method-based organization for multiple actions

Middleware Modules

Middleware modules provide request processing and context modification capabilities.

📁 Type Definitions: types/middleware.d.ts

interface MiddlewareModule {
  handler?: MiddlewareHandler | MiddlewareHandlers;
}

interface MiddlewareHandler {
  (
    context: MiddlewareContext,
    next: MiddlewareNext
  ): MiddlewareResult | Promise<MiddlewareResult>;
}

Key Features:

  • HTTP method-specific middleware handlers
  • Context modification and state management
  • Chainable middleware execution
  • Type-safe context and response handling

Core Types

HTTP Types

Standard HTTP request/response handling with error management and state management.

📁 Type Definitions: types/http.d.ts

interface FetchContext<Params = Record<string, string>> {
  request: Request;
  params: Readonly<Params>;
  state: State;
  error?: HTTPException;
}

interface HTTPException extends Error {
  expose?: boolean;
  status?: number;
  statusText?: string;
}

Metadata Types

Comprehensive HTML document metadata management for dynamic head elements.

📁 Type Definitions: types/meta.d.ts

interface Meta {
  title?: string;
  description?: string;
  link?: LinkDescriptor[];
  meta?: MetaDescriptor[];
  script?: ScriptDescriptor[];
  style?: StyleDescriptor[];
  base?: BaseDescriptor;
}

Rendering Types

Server-side and client-side rendering interfaces with streaming support.

📁 Type Definitions: types/render.d.ts

interface ServerRender<Component, Data, Options, Result> {
  (
    component: Component,
    data: Data,
    options: Options
  ): Result | Promise<Result>;
}

interface ClientRender<Component, Data, Options, Result> {
  (
    component: Component,
    data: Data,
    options: Options
  ): Result | Promise<Result>;
}

Design Principles

Technology Agnostic

The schema is designed to be framework-agnostic, allowing different frontend technologies to implement the same module format while maintaining their unique characteristics.

Type Safety

Comprehensive TypeScript definitions ensure type safety across the entire application stack, from server to client.

Web Standards

Built on web standards like Fetch API, ReadableStream, and standard HTTP methods, ensuring long-term compatibility.

Modularity

Clear separation of concerns with distinct module types for different responsibilities, enabling better code organization and reusability.

Type Definitions Entry Point

📁 Main Entry: types/index.d.ts - Exports all type definitions

Usage

This schema serves as a foundation for implementing module-based web applications. Framework implementations can use these types to ensure consistency and interoperability across different technology stacks.

The type definitions provide detailed JSDoc comments for each interface and method, making them self-documenting for developers implementing this standard.