Sanity Library Reference Docs
    Preparing search index...
    • Returns the panel view and onClose handler.

      Throws when the component does not render in a panel view.

      Returns {
          onClose: () => void;
          view: ApplicationInterfaceBase & {
              metadata: ApplicationInterfacePlacementMetadata | null;
              type: "panel";
          };
      }

      export default function MyPanel() {
      const {view, onClose} = usePanel()
      return (
      <header>
      <h2>{view.title}</h2>
      <button onClick={onClose}>Close</button>
      </header>
      )
      }