Skip to main content
sunpeak API

Overview

Returns a function to request the host to tear down the app. If the host approves, it will send the standard teardown signal back (triggering any useTeardown callbacks) before unmounting the iframe. This is for app-initiated close, as opposed to host-initiated teardown handled by useTeardown.

Wraps requestTeardown

MCP Apps SDK reference

Import

import { useRequestTeardown } from 'sunpeak';

Signature

function useRequestTeardown(): () => Promise<void>

Returns

requestTeardown
() => Promise<void>
Function to request the host to tear down this app.

Usage

import { useRequestTeardown } from 'sunpeak';

function MyResource() {
  const requestTeardown = useRequestTeardown();

  return (
    <button onClick={() => requestTeardown()}>
      Close App
    </button>
  );
}