# loadflux

> Lightweight server monitoring dashboard for Node.js - embed Grafana like metrics in your existing server

Latest version **2.0.0** (published 2026-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install loadflux
pnpm add loadflux
yarn add loadflux
bun add loadflux
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-10-10 |
| First published | 2026-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 4 |
| Unpacked size | 808 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Kritebh Lagan Bibhakar |
| Maintainers | kritebh |
| Keywords | monitoring, dashboard, metrics, apm, performance, express, fastify, nestjs, server-monitoring, api-monitoring, nodejs, status, charts, observability, monitoring-page |

## Links

- npm: https://www.npmjs.com/package/loadflux
- Repository: https://github.com/kritebh/loadflux
- Homepage: https://loadflux.kritebh.dev
- Issues: https://github.com/kritebh/loadflux/issues
- npm.io page: https://npm.io/package/loadflux

## Dependencies (4)

- [bcryptjs](https://npm.io/package/bcryptjs.md) ^3.0.2
- [node-cron](https://npm.io/package/node-cron.md) ^3.0.3
- [on-headers](https://npm.io/package/on-headers.md) ^1.0.2
- [better-sqlite3](https://npm.io/package/better-sqlite3.md) ^11.9.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-10-10
- 1.1.0 — 2026-07-21
- 1.0.3 — 2026-06-10
- 1.0.2 — 2026-03-16
- 1.0.1 — 2026-03-10
- 1.0.0 — 2026-03-10

## README

# LoadFlux

Lightweight, embeddable server monitoring dashboard for Node.js. Drop a single middleware into your Express or Fastify app and get a full Grafana-like dashboard no separate process, no external services.

![Dashboard](https://raw.githubusercontent.com/kritebh/loadflux/refs/heads/main/screenshots/dashboard.png)

## Features

- **Real-time dashboard** with live SSE updates every 2 seconds
- **System metrics** — CPU, memory, disk usage, network I/O
- **App metrics** — heap usage, event loop delay, GC pause time
- **Endpoint analytics** — request count, latency percentiles (p50/p90/p95/p99), error rates
- **Error tracking** — error log with status codes, durations, and stack traces
- **Configurable retention** and slow request thresholds
- **Password-protected** with bcrypt hashing and HMAC-SHA256 session tokens
- **Dark/light theme** with **custom from/to date-time** ranges (default rolling last hour) on historical pages
- **Search** on Endpoints and Errors; **HTTP status filter** on Errors
- **SQLite by default** (zero-config), optional MongoDB support
- **JSON export** for all metrics
- Works with **Express**, **Fastify**, and **NestJS** (via their underlying framework)

## Quick Start

```bash
npm install loadflux
```

### Express

```typescript
import express from "express";
import { loadflux } from "loadflux";

const app = express();

app.use(loadflux({
  auth: { username: "admin", password: "secret" }
}));

app.get("/api/users", (req, res) => res.json({ users: [] }));

app.listen(3000);
// Dashboard at http://localhost:3000/loadflux
```

### Fastify

```typescript
import Fastify from "fastify";
import { loadfluxFastify } from "loadflux";

const app = Fastify();

app.register(loadfluxFastify({
  path: "/monitor",
  auth: { username: "admin", password: "secret" }
}));

app.get("/api/users", async () => ({ users: [] }));

await app.listen({ port: 3000 });
// Dashboard at http://localhost:3000/monitor
```

## Documentation

For detailed guides, all dashboard pages, configuration reference, and more — visit the full docs:

**[loadflux.dev](https://loadflux.kritebh.dev)**

## Configuration

```typescript
loadflux({
  // Dashboard URL path (default: "/loadflux")
  path: "/loadflux",

  // Authentication credentials
  auth: {
    username: "admin",
    password: "secret",
  },

  // Database backend
  database: {
    adapter: "sqlite",             // "sqlite" (default) or "mongodb"
    connectionString: "./loadflux.db", // SQLite path or MongoDB URI
  },

  // Collection intervals
  collection: {
    systemInterval: 5000,    // System metrics polling (ms)
    aggregationWindow: 5000, // Request aggregation flush (ms)
  },

  // Data retention
  retention: {
    days: 90,                 // Keep metrics for N days
    cronExpression: "0 2 * * *", // Cleanup schedule
  },

  // Flag requests slower than this (ms)
  slowRequestThreshold: 500,

  // Routes to exclude from monitoring
  excludeRoutes: ["/health", "/ready"],

  // Optional: see Configuration Options in the docs for disableOnLocalhost,
  // listenHost (LOADFLUX_LISTEN_HOST / HOST), and trustProxy (LOADFLUX_TRUST_PROXY).
});
```

Environment variables:

```bash
LOADFLUX_USERNAME=admin
LOADFLUX_PASSWORD=secret
# LOADFLUX_LISTEN_HOST=0.0.0.0   # bind host hint for disableOnLocalhost
# LOADFLUX_TRUST_PROXY=1        # behind a trusted reverse proxy only
```

## Requirements

- Node.js >= 22.0.0

## Tech Stack

| Component | Technology |
|-----------|------------|
| Server metrics engine | TypeScript, better-sqlite3, node-cron |
| Dashboard UI | React 19, Tailwind CSS, Chart.js |
| Real-time updates | Server-Sent Events (SSE) |
| Auth | bcryptjs + HMAC-SHA256 tokens |
| Build | tsup (server), Vite (UI) |

## Development

```bash
# Install dependencies
npm install

# Build everything (server + UI)
npm run build

# Dev mode (server with watch)
npm run dev

# Dev mode (UI with Vite dev server)
npm run dev:ui

# Run tests
npm test

# Run the example server (requires build first)
node examples/test-server.mjs
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/loadflux · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
