Get component instance count

webflow.getInstanceCount(component)

Gets the number of instances of a component.

Syntax

webflow.getInstanceCount(component: Component): Promise<number>

Returns

Promise<number>

A Promise that resolves to the number of instances of the component across the entire site.

Example

// Audit component usage across the site
const components = await webflow.getAllComponents();
for (const component of components) {
const name = await component.getName();
const count = await component.getInstanceCount();
console.log(`${name}: ${count} instances`);
}
// Guard against removing a component that's still in use
const hero = components[0];
const instanceCount = await hero.getInstanceCount();
if (instanceCount > 0) {
console.log(`Cannot safely remove — ${instanceCount} instances exist`);
} else {
await webflow.unregisterComponent(hero);
}

Designer Ability

Checks for authorization only

Designer AbilityPermissionLocaleBranchWorkflowSitemode
canAccessCanvasanyanyanyanyany