Skip to content

kerothebosa/ui-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@kerothebosa/ui-skeleton-net

Network-aware skeleton loading for modern web apps.
Patch fetch and XMLHttpRequest, then drive skeleton visibility from real request lifecycle with predictable timing controls and typed hooks. npm downloads CI Pages npm version bundle size license

Why This Package

Most loading UIs rely on scattered isLoading flags and drift away from actual network behavior.
@kerothebosa/ui-skeleton-net centralizes this at the transport layer and gives you consistent skeleton timing across your app.

Highlights

  • Framework-agnostic runtime integration
  • Intercepts both fetch and XMLHttpRequest
  • Timing controls to reduce flicker (showDelayMs, minVisibleMs)
  • Typed lifecycle hooks for observability and analytics
  • Publish-ready distribution (ESM, CJS, d.ts, styles.css)

Installation

npm install @kerothebosa/ui-skeleton-net

Quick Start

import { SkeletonEnhancer } from "@kerothebosa/ui-skeleton-net";
import "@kerothebosa/ui-skeleton-net/styles.css";

const enhancer = new SkeletonEnhancer({
  skeletonSelector: "#content",
  showDelayMs: 120,
  minVisibleMs: 180,
  requestTimeoutMs: 10_000,
  timeoutMode: "abort",
  enabledInterceptors: ["fetch", "xhr"]
});

enhancer.start();

Styling Requirement

The stylesheet is not auto-injected by bundlers. Import it explicitly:

import "@kerothebosa/ui-skeleton-net/styles.css";

Configuration At A Glance

Option Type Purpose
showDelayMs number Delay skeleton reveal to avoid flashing on fast requests.
minVisibleMs number Keep skeleton visible long enough for stable perceived UX.
requestTimeoutMs number Timeout threshold for request lifecycle handling.
timeoutMode "abort" | "synthetic" Abort transport or only finalize UI lifecycle.
enabledInterceptors Array<"fetch" | "xhr"> Select observed network transports.
skeletonVisuals object Visual mode, animation, theme, and adaptive placeholder behavior.

Full options and types:
https://kerothebosa.github.io/ui-skeleton/api-reference

Events And Hooks Example

const enhancer = new SkeletonEnhancer({
  hooks: {
    onRequestStart: ({ requestId, method, url }) =>
      console.log("request:start", requestId, method, url),
    onRequestEnd: ({ requestId, status, durationMs }) =>
      console.log("request:end", requestId, status, durationMs),
    onSkeletonShow: ({ requestId }) => console.log("skeleton:show", requestId),
    onSkeletonHide: ({ requestId }) => console.log("skeleton:hide", requestId),
    onError: ({ requestId, error }) => console.error("error", requestId, error.message)
  }
});

Demo

Documentation

Browser And Runtime Support

  • Modern browsers with fetch and XMLHttpRequest
  • Node.js >=18 for tooling, CI, and local docs/demo builds

Development Scripts

  • npm run build - Build package outputs (dist/)
  • npm run demo:dev - Run local playground demo
  • npm run docs:dev - Run VitePress docs locally
  • npm run ci - Lint + typecheck + tests + e2e + pack check

Project Standards

  • Contributing: CONTRIBUTING.md
  • Code of Conduct: CODE_OF_CONDUCT.md
  • Security: SECURITY.md
  • Changelog: CHANGELOG.md
  • License: LICENSE

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors