Skip to main content
destroy() Destroys the call object and frees all associated resources. After destroy() completes, isDestroyed() returns true and any further method calls on the instance will throw an error. If the call is still active when destroy() is called, it will leave the call automatically before releasing resources — so you can call destroy() directly without a prior leave(). Call leave() instead when you want to end the current session but reuse the call object for a future join() or want access to the call object’s state before destroying it.
By default, if you attempt to create a new call object without first destroying the old one, the factory method will throw an error to prevent event handling conflicts. You must explicitly opt in to multiple-instance mode if you want to create more than one call object. See the Multiple Instances guide for details.

Return value

Returns a Promise<void> that resolves once all resources have been released.

Example

// When the user is completely done with the call
async function endSession() {
  await call.leave();
  await call.destroy();
  callRef.current = null;
}

// Or listen for the event to clean up references
call.on('call-instance-destroyed', () => {
  callRef.current = null;
});

See also