Advanced / Owner & Introspection

getOwner

Returns the current reactive owner — the lifecycle node that the next cleanup() / onCleanup() / createSignal() etc. Will be attached to.

Returns null if called outside any owner. Capture the owner with getOwner() and re-enter it later with runWithOwner(owner, fn) to attach disposables created from a callback (event handler, async resolution, etc.) back to a component's lifecycle.


Import

import { getOwner } from "solid-js";

Type signature

function getOwner(): Owner | null;

Examples

function defer<T>(fn: () => T) {
const owner = getOwner();
queueMicrotask(() => runWithOwner(owner, fn));
}

NoOwnerError

class NoOwnerError extends Error {
constructor() {
super(__DEV__ ? "Context can only be accessed under a reactive root." : "");
}
}
Last updated: 7/4/26, 6:21 PMEdit this pageReport an issue with this page