diff --git a/src/frontend/src/components/starlight/Sidebar.astro b/src/frontend/src/components/starlight/Sidebar.astro
index b4c6333d65..6f30255d3c 100644
--- a/src/frontend/src/components/starlight/Sidebar.astro
+++ b/src/frontend/src/components/starlight/Sidebar.astro
@@ -6,6 +6,7 @@ import MobileSiteLinks from '@components/starlight/MobileSiteLinks.astro';
import { Badge, Icon, LinkButton } from '@astrojs/starlight/components';
import { sidebarTopics } from '../../../config/sidebar/sidebar.topics.js';
import { referenceTopics } from '../../../config/sidebar/reference.topics.js';
+import { getApiSidebarTreeSrc } from '@utils/api-sidebar-tree-src';
import '../../styles/search-controls.css';
const routeData = Astro.locals.starlightRoute;
@@ -22,6 +23,11 @@ const apiLang = pageId.startsWith('reference/api/typescript')
: undefined;
const sidebar = routeData?.sidebar ?? [];
const topics = topicState?.topics ?? [];
+// Package/module pages render a small spine; the full tree loads on the client
+// from a content-versioned URL so the edge can cache it indefinitely.
+const apiSidebarTreeSrc = isApiRefPage
+ ? await getApiSidebarTreeSrc(Astro.url.pathname, import.meta.env.BASE_URL.replace(/\/$/, ''))
+ : undefined;
type SidebarTopicOption = {
label: string;
@@ -122,6 +128,7 @@ const hasTopicsList = Boolean(currentTopic && effectiveTopics.length > 0);
class="topics-sidebar"
data-api-ref={isApiRefPage || undefined}
data-api-lang={apiLang}
+ data-api-sidebar-tree={apiSidebarTreeSrc}
data-topic-nav={hasTopicSidebar || undefined}
>
@@ -1246,6 +1253,10 @@ const hasTopicsList = Boolean(currentTopic && effectiveTopics.length > 0);