Skip to main content
Version: v10.5.0

Connect your app

Your app talks to HyperFlow through @hyper-fetch/plugin-devtools. You add the plugin to the client once, and every request, cache change and queue event of that client appears in HyperFlow. It takes three steps and about two minutes.

What you'll set up
  1. Install the plugin.
  2. Add it to your client, only in development.
  3. Check that your app shows up in HyperFlow.

1. Install the plugin​

npm install @hyper-fetch/plugin-devtools @hyper-fetch/sockets

The plugin reaches HyperFlow over a WebSocket built with @hyper-fetch/sockets, so both packages are needed.


2. Add it to your client​

Pass DevtoolsPlugin to addPlugin. The appName is the name HyperFlow shows, so give every app a different one.

api/client.ts
import { createClient } from "@hyper-fetch/core";
import { DevtoolsPlugin } from "@hyper-fetch/plugin-devtools";

export const client = createClient({ url: "https://api.example.com" });

if (process.env.NODE_ENV === "development") {
client.addPlugin(DevtoolsPlugin({ appName: "Acme Store" }));
}

The plugin connects as soon as it is added, so the condition keeps it out of production. Use the variable your bundler provides, such as import.meta.env.DEV in Vite.

Keep the plugin out of the production bundle

A static import ships the plugin's code even when the condition is false. Load it with a dynamic import, and bundlers leave it out of production builds:

api/client.ts
export const client = createClient({ url: "https://api.example.com" });

if (process.env.NODE_ENV === "development") {
void import("@hyper-fetch/plugin-devtools").then(({ DevtoolsPlugin }) => {
client.addPlugin(DevtoolsPlugin({ appName: "Acme Store" }));
});
}

With this setup you can install the plugin as a dev dependency (npm install -D).


3. Check the connection​

Open HyperFlow, then start your app and let it send a request. Your app appears on the Applications screen with a green Connected dot. Select it to open its start page.

Connected apps come first. An app that closed stays listed as Disconnected, with the data HyperFlow collected.

You can start HyperFlow and your app in any order. While HyperFlow is closed, the plugin retries the connection with a growing delay, starting at 3 seconds, up to 100 times. It keeps the latest 1,000 events meanwhile and sends them once it connects.

If your app does not show up, see Troubleshooting.


Inspect sockets and dbs​

Pass the sockets and @hyper-fetch/db dbs you want to see. They appear under the same app, on the Sockets and DB pages.

api/client.ts
import { DevtoolsPlugin } from "@hyper-fetch/plugin-devtools";

import { db } from "./db";
import { socket } from "./socket";

client.addPlugin(
DevtoolsPlugin({
appName: "Acme Store",
sockets: [socket],
dbs: [db],
}),
);

Node.js backends and other runtimes​

The plugin works wherever the client runs: Node.js servers, scripts, workers, Bun, Deno and React Native. Give the backend its own appName and an environment so you can tell it apart from the frontend.

On Node.js 22+, Bun and Deno the plugin uses the global WebSocket. On Node.js 18 and 20, install ws and pass it:

server/client.ts
import { createClient } from "@hyper-fetch/core";
import { DevtoolsPlugin } from "@hyper-fetch/plugin-devtools";
import { WebSocket } from "ws";

export const client = createClient({ url: "https://api.example.com" }).addPlugin(
DevtoolsPlugin({
appName: "Acme API",
environment: "server",
WebSocket: WebSocket as unknown as typeof globalThis.WebSocket,
}),
);

Several apps at once​

Each client with the plugin becomes one application in HyperFlow, keyed by its appName. A frontend, a backend and a worker can all be connected at the same time. When an app reconnects under the same name, HyperFlow keeps its history and settings.

The environment option shows as a badge on the app's card, such as development or staging. Use it when you run the same app in several places.


Plugin options​

OptionDefaultWhat it does
appNamerequiredThe name HyperFlow shows. Apps with the same name are treated as one app.
environmentthe appNameA badge on the app's card, shown when it differs from the name.
url"ws://localhost:2137"Where HyperFlow listens. Change it when you change the port.
sockets[]@hyper-fetch/sockets instances to show on the Sockets page.
dbs[]@hyper-fetch/db dbs to show on the DB page.
WebSocketthe global WebSocketThe WebSocket class to connect with. Pass the one from ws on Node.js 18 and 20.
debugfalseLogs the plugin's connection events through the client's logger.

Summary

You installed the plugin, added it to your client in development, and saw your app connect. Next, take the interface tour to find your way around.


Next steps​

The runnable Devtools example adds the plugin in development only, as shown above. The DevtoolsPlugin API reference lists its options and types.