mcp-use TypeScript API
    Preparing search index...

    Function getPublicBaseUrl

    • Return the request-resolved base URL for files in the project's public/ directory.

      Returns string

      The absolute public-folder base URL with a trailing slash, or an empty string when no injected view configuration is available.

      The returned URL always includes a trailing slash. Append public-folder paths without a leading slash. The URL is resolved for the current request, so it remains correct behind proxies, tunnels, and MCP_ASSETS_URL.

      Outside a synthesized browser view document, the function returns an empty string.

      import { getPublicBaseUrl } from "mcp-use/react";

      const publicBaseUrl = getPublicBaseUrl();
      const stylesheetUrl = `${publicBaseUrl}assets/vendor.css`;
      const wasmUrl = `${publicBaseUrl}doom/websockets-doom.wasm`;