Advanced / Diagnostics & Dev Hooks

dispatchAsInteraction

Runs fn as a handler of the DOM event e, inside the interaction frame the runtime opens for e — the one its own listeners for e run in. A listener the runtime did not attach (a router's document click handler, analytics, drag-and-drop) wraps its body in this, so its work joins the same interaction record as the component handlers for the same event instead of running outside one. In production builds this is fn().

Use it for listeners that respond to the user (click, submit, keydown), not for passive ones (mousemove, focusin preloads), which would each record an interaction.


Import

import { dispatchAsInteraction } from "@solidjs/web";

Type signature

function dispatchAsInteraction<T>(e: Event, fn: () => T): T;

Parameters

e

  • Type: Event

fn

  • Type: () => T

Examples

document.addEventListener("click", (e) =>
dispatchAsInteraction(e, () => handleAnchorClick(e))
);

Learn more

Last updated: 10/15/26, 9:29 AMEdit this pageReport an issue with this page