Skip to main content

Overview

Returns information about the host application, including its name, version, and supported capabilities.

Import

import { useHostInfo } from 'sunpeak';

Signature

function useHostInfo(): {
  hostVersion: HostVersion | undefined;
  hostCapabilities: HostCapabilities | undefined;
}

Returns

hostVersion
HostVersion | undefined
Host application name and version.
hostCapabilities
HostCapabilities | undefined
Host-supported capabilities.

HostVersion

name
string
Host application name.
version
string
Host application version.

HostCapabilities

serverTools
boolean
Whether the host supports calling server tools.
Whether the host supports opening external links.
logging
boolean
Whether the host supports structured logging.
messages
boolean
Whether the host supports sending messages.
displayModes
boolean
Whether the host supports display mode changes.

Usage

import { useHostInfo } from 'sunpeak';

function MyResource() {
  const { hostVersion, hostCapabilities } = useHostInfo();

  return (
    <div>
      <p>Host: {hostVersion?.name} {hostVersion?.version}</p>
      <p>Can call tools: {hostCapabilities?.serverTools ? 'Yes' : 'No'}</p>
    </div>
  );
}