tutorial

How to Monitor Trident.js with Vigilmon

Add production-grade uptime monitoring to your Trident.js reactive app — health endpoint, Vigilmon HTTP and keyword monitors, and alert configuration.

How to Monitor Trident.js with Vigilmon

Trident.js is a minimal reactive JavaScript library based on proxies for declarative, data-driven UI rendering. It keeps your reactive layer lean — but a small runtime won't tell you when your server goes down or a deploy breaks your UI. You need an external monitor watching your production URL.

This tutorial walks through:

  • A /health endpoint in your Trident.js-backed server
  • An HTTP uptime monitor in Vigilmon
  • A keyword monitor that confirms your reactive UI is loading
  • Slack or email alerts when anything goes wrong

The full setup takes about 15 minutes.


Step 1: Add a health endpoint to your server

Trident.js renders on the client side, served from a static file server or a backend of your choice. Add a /health route to confirm the server is up and your assets are being served:

// server.js (Express)
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const app = express();

app.use(express.static(path.join(__dirname, 'public')));

app.get('/health', (req, res) => {
  res.json({
    status: 'ok',
    service: 'tridentjs-app',
    timestamp: new Date().toISOString(),
  });
});

app.listen(3000);

For a deeper check that exercises any backend API your Trident.js app calls:

app.get('/health', async (req, res) => {
  const checks = {};
  let healthy = true;

  try {
    const r = await fetch(process.env.API_URL + '/ping', {
      signal: AbortSignal.timeout(3000),
    });
    checks.api = r.ok ? 'ok' : 'error';
    if (!r.ok) healthy = false;
  } catch {
    checks.api = 'error';
    healthy = false;
  }

  res.status(healthy ? 200 : 503).json({
    status: healthy ? 'ok' : 'degraded',
    checks,
    timestamp: new Date().toISOString(),
  });
});

A 503 on failure means Vigilmon immediately detects the outage without needing a body check.

Verify locally:

node server.js
curl http://localhost:3000/health
# {"status":"ok","service":"tridentjs-app","timestamp":"..."}

Step 2: Set up an HTTP monitor in Vigilmon

Deploy your app then connect it to Vigilmon:

  1. Sign up at vigilmon.online — free, no card required
  2. Click New Monitor → HTTP
  3. URL: https://yourapp.example.com/health
  4. Check interval: 1 minute (paid) or 5 minutes (free)
  5. Expected status: 200
  6. Save

Vigilmon probes from multiple regions. If your /health route returns anything other than 200 — or times out — you get alerted immediately.


Step 3: Add a keyword monitor for UI loading

Your health endpoint confirms the server is up. A keyword monitor confirms that your Trident.js bundle is actually loading and the page HTML contains the expected markup — critical since a misconfigured CDN or broken bundle can leave the server running while your UI is broken.

In Vigilmon:

  1. Click New Monitor → Keyword
  2. URL: https://yourapp.example.com/
  3. Keyword: a string that only appears when the page loads correctly — your app title, a root element ID, or a static label
  4. Match type: Contains
  5. Expected status: 200
  6. Save

If a deploy corrupts your bundle or misconfigures your asset paths, only the keyword monitor catches it.


Step 4: Configure alerts

Go to Notifications → New Channel in Vigilmon and pick your channel type:

Slack:

  1. Create an incoming webhook at api.slack.com/apps
  2. Paste the URL into Vigilmon's Slack channel config
  3. Enable it on both your monitors

Email:

  1. Add your email address as a notification channel
  2. Enable it on the monitors you want coverage for

When your app goes down, the alert lands within the check interval:

🔴 DOWN: yourapp.example.com/health
Status: 503
Region: EU-West
3 minutes ago

When it recovers:

✅ RECOVERED: yourapp.example.com/health
Downtime: 7 minutes

For critical apps, enable both Slack (immediate) and email (paper trail).


Step 5: Heartbeat monitoring for data sync and build jobs

If your app syncs data from an external source or runs scheduled builds, HTTP monitoring won't catch a silent failure there.

Add a heartbeat ping at the end of each successful job:

// jobs/sync-data.js
import { fetchAndCacheData } from '../lib/data.js';

async function run() {
  await fetchAndCacheData();

  const heartbeatUrl = process.env.VIGILMON_SYNC_HEARTBEAT;
  if (heartbeatUrl) {
    await fetch(heartbeatUrl);
  }
}

run().catch((err) => {
  console.error('Sync failed:', err);
  process.exit(1);
});

In Vigilmon, create a Heartbeat Monitor:

  1. Click New Monitor → Heartbeat
  2. Set the expected interval to match your job schedule
  3. Copy the ping URL
  4. Set VIGILMON_SYNC_HEARTBEAT=<url> in your environment

If the job stops running or throws, Vigilmon alerts you after one missed interval.


Step 6: Public status page

Go to Status Pages → New Status Page in Vigilmon, add your monitors, and publish. Drop the URL in your README or on error pages:

Service unavailable. Check our status page: https://status.yourapp.example.com

Each monitor also generates a live badge:

![App Status](https://vigilmon.online/badge/your-monitor-slug)

What you've built

| What | How | |------|-----| | Health endpoint | /health route in Express server | | HTTP uptime check | Vigilmon HTTP monitor | | UI loading check | Vigilmon keyword monitor on home page | | Slack/email alerts | Vigilmon notification channels | | Job monitoring | Heartbeat ping in sync/build scripts | | Status page | Vigilmon public status page |

Trident.js keeps your reactive layer minimal and fast. Vigilmon keeps your uptime visible when something breaks in production.


Next steps

  • Add monitors for the API endpoints your Trident.js state layer fetches from
  • Watch response time trends — Vigilmon charts latency over time, and gradual slowdowns often appear before a full outage
  • Add a heartbeat for every background data sync or build job

Get started free at vigilmon.online.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →