โ† All examples

Response headers

The server can trigger client events, redirect, or reload the page from response headers โ€” without custom JavaScript in the response body.

Click the first button and watch the event log.

Event log ready.

Headers

HeaderEffect
Minu-Trigger: pingFires minu:trigger:ping on the requestor.
Minu-Redirect: /urlNavigates with location.assign.
Minu-Refresh: trueReloads the page.

How it works

  1. The request completes normally; headers are inspected before the body is swapped.
  2. Minu-Trigger is split on commas and each name dispatches an event on the trigger element.
  3. The event bubbles, so a single document listener can handle every trigger.
  4. Minu-Redirect and Minu-Refresh run before the swap.
  5. The redirect button opens a small landing page; the refresh button reloads this page.
// server
res.setHeader('Minu-Trigger', 'ping');
res.end('<p>Done</p>');

// client
document.addEventListener('minu:trigger:ping', (event) => {
    console.log('server asked for', event.detail.name);
});