mcp-use TypeScript API
    Preparing search index...

    Function useOpenExternal

    • Returns a callback that asks the host to open a URL outside the view.

      Returns (args: { url: string }) => Promise<void>

      Requires the host openLinks capability; otherwise the returned promise rejects before any wire traffic. The host decides how (and whether) to open the link — typically in the user's browser, often behind a confirmation prompt — so treat it as a request, not a guaranteed navigation. Views run sandboxed and cannot navigate the user themselves; this is the supported way to link out.

      The returned callback is referentially stable for the lifetime of the mounted runtime.

      function DocsLink() {
      const openExternal = useOpenExternal();
      return (
      <button
      type="button"
      onClick={() => {
      void openExternal({ url: "https://example.com/docs" });
      }}
      >
      Open docs
      </button>
      );
      }