@@ -6,6 +6,7 @@ import { preload } from "react-dom";
66
77import { getEnv } from "@vercel/functions" ;
88import { compact } from "es-toolkit/array" ;
9+ import { HydrationBoundary } from "jotai-ssr" ;
910
1011import { DocsV1Read , DocsV2Read } from "@fern-api/fdr-sdk/client/types" ;
1112import { isNonNullish } from "@fern-api/ui-core-utils" ;
@@ -28,6 +29,7 @@ import { DarkCode } from "@/state/dark-code";
2829import { Domain } from "@/state/domain" ;
2930import { LaunchDarklyInfo } from "@/state/feature-flags" ;
3031import { DefaultLanguage } from "@/state/language" ;
32+ import { isSidebarFixedAtom } from "@/state/layout" ;
3133import { SetLogoText } from "@/state/logo-text" ;
3234import { RootNodeProvider , SetBasePath } from "@/state/navigation" ;
3335import {
@@ -85,59 +87,71 @@ export default async function Layout({
8587 getSidebarRootNodeIdToChildToParentsMap ( sidebarRootNodes ) ;
8688
8789 return (
88- < ThemeProvider
89- hasLight = { Boolean ( colors . light ) }
90- hasDark = { Boolean ( colors . dark ) }
91- lightThemeColor = { colors . light ?. themeColor }
92- darkThemeColor = { colors . dark ?. themeColor }
90+ < HydrationBoundary
91+ hydrateAtoms = { [
92+ [
93+ isSidebarFixedAtom ,
94+ ! ! colors . dark ?. sidebarBackground ||
95+ ! ! colors . light ?. sidebarBackground ||
96+ layout . isHeaderDisabled ,
97+ ] ,
98+ ] }
99+ options = { { enableReHydrate : true } }
93100 >
94- < RootNodeProvider
95- sidebarRootNodesToChildToParentsMap = {
96- sidebarRootNodesToChildToParentsMap
97- }
101+ < ThemeProvider
102+ hasLight = { Boolean ( colors . light ) }
103+ hasDark = { Boolean ( colors . dark ) }
104+ lightThemeColor = { colors . light ?. themeColor }
105+ darkThemeColor = { colors . dark ?. themeColor }
98106 >
99- < Domain value = { domain } />
100- < SetBasePath value = { basePath || "/" } />
101- { /** HACKHACK: this is a hack to set the logo text to "Docs" for Cohere, this needs to be moved into docs.yml */ }
102- < SetLogoText text = { domain . includes ( "cohere" ) ? "Docs" : undefined } />
103- { config . defaultLanguage != null && (
104- < DefaultLanguage language = { config . defaultLanguage } />
105- ) }
106- < DarkCode value = { edgeFlags . isDarkCodeEnabled } />
107- < Whitelabeled value = { edgeFlags . isWhitelabeled } />
108- < SetColors colors = { colors } />
109- < SetIsAskAiEnabled isAskAiEnabled = { edgeFlags . isAskAiEnabled } />
110- < SetIsDefaultSearchFilterOff
111- isDefaultSearchFilterOff = { edgeFlags . isDefaultSearchFilterOff }
112- />
113- < FernUser domain = { domain } host = { host } />
114- < GlobalStyles
115- domain = { domain }
116- layout = { layout }
117- fonts = { fonts }
118- light = { colors . light }
119- dark = { colors . dark }
120- inlineCss = { config . css ?. inline }
121- />
122- < FeatureFlagProvider featureFlagsConfig = { { launchDarkly } } >
123- { children }
124- </ FeatureFlagProvider >
125- < React . Suspense fallback = { null } >
126- { ! edgeFlags . isSearchDisabled && ! isLocalEnvironment && (
127- < SearchV2 domain = { domain } />
107+ < RootNodeProvider
108+ sidebarRootNodesToChildToParentsMap = {
109+ sidebarRootNodesToChildToParentsMap
110+ }
111+ >
112+ < Domain value = { domain } />
113+ < SetBasePath value = { basePath || "/" } />
114+ { /** HACKHACK: this is a hack to set the logo text to "Docs" for Cohere, this needs to be moved into docs.yml */ }
115+ < SetLogoText text = { domain . includes ( "cohere" ) ? "Docs" : undefined } />
116+ { config . defaultLanguage != null && (
117+ < DefaultLanguage language = { config . defaultLanguage } />
128118 ) }
129- </ React . Suspense >
130- { jsConfig != null && < JavascriptProvider config = { jsConfig } /> }
131- { VERCEL_ENV === "production" && (
132- < CustomerAnalytics
133- config = { mergeCustomerAnalytics (
134- deprecated_customerAnalytics ,
135- config . analyticsConfig
136- ) }
119+ < DarkCode value = { edgeFlags . isDarkCodeEnabled } />
120+ < Whitelabeled value = { edgeFlags . isWhitelabeled } />
121+ < SetColors colors = { colors } />
122+ < SetIsAskAiEnabled isAskAiEnabled = { edgeFlags . isAskAiEnabled } />
123+ < SetIsDefaultSearchFilterOff
124+ isDefaultSearchFilterOff = { edgeFlags . isDefaultSearchFilterOff }
125+ />
126+ < FernUser domain = { domain } host = { host } />
127+ < GlobalStyles
128+ domain = { domain }
129+ layout = { layout }
130+ fonts = { fonts }
131+ light = { colors . light }
132+ dark = { colors . dark }
133+ inlineCss = { config . css ?. inline }
137134 />
138- ) }
139- </ RootNodeProvider >
140- </ ThemeProvider >
135+ < FeatureFlagProvider featureFlagsConfig = { { launchDarkly } } >
136+ { children }
137+ </ FeatureFlagProvider >
138+ < React . Suspense fallback = { null } >
139+ { ! edgeFlags . isSearchDisabled && ! isLocalEnvironment && (
140+ < SearchV2 domain = { domain } />
141+ ) }
142+ </ React . Suspense >
143+ { jsConfig != null && < JavascriptProvider config = { jsConfig } /> }
144+ { VERCEL_ENV === "production" && (
145+ < CustomerAnalytics
146+ config = { mergeCustomerAnalytics (
147+ deprecated_customerAnalytics ,
148+ config . analyticsConfig
149+ ) }
150+ />
151+ ) }
152+ </ RootNodeProvider >
153+ </ ThemeProvider >
154+ </ HydrationBoundary >
141155 ) ;
142156}
143157
0 commit comments