Files
bootnode/console/components/brand-provider.tsx
zooqueenandHanzo Dev df50d16787
Hanzo CI/CD / cicd (push) Failing after 1h10m29s
CI/CD / cicd (push) Failing after 2h37m43s
Render every console page with the brand of the host serving it
A static export has no host when it prerenders, so BrandProvider renders the
tree only once the browser has resolved the host, pages that show the brand
are client components, the static head names no brand, and the title and
favicon come from the host. The chain page keeps its static params and
metadata on the server and renders its body on the client, with RPC endpoints
on the brand's API origin at /v1/rpc/{chain}/{network}.

Hanzo's API origin is web3.hanzo.ai itself. The node fleet view, its landing
strip and its nav link belong to the brand that operates a fleet, which is
Lux alone. llms.txt, one file for every host, names no brand and points at
each host's own /docs/api.

Marketing copy states no certification the company does not hold and no
unmeasured uptime, latency, volume or response-time figure. Every internal
link points at a page that exists, every catalog chain is prerendered, and
the routes test holds page bodies to zero dead links.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-15 12:01:27 -07:00

53 lines
1.9 KiB
TypeScript

"use client"
// BrandProvider — publishes the hostname-resolved brand to the tree.
//
// `getBrand()` is a pure function of the hostname, and a static export has no
// hostname when it prerenders. So the tree renders only in the browser, once
// the host is known: the exported HTML carries no brand, and every client
// component that reads the brand renders with the brand of the host it is
// served on. Nothing renders twice with two different brands, so there is no
// hydration mismatch to repair.
//
// A server component is rendered at build time, where the brand is always the
// default one, so a page that shows the brand is a client component, and
// server-authored markup names the brand through <BrandName />.
//
// It also owns the two brand-derived document facts a static <head> cannot
// know: the title and the favicon.
import { createContext, useContext, useEffect, useState } from "react"
import { getBrand, type BrandConfig } from "@/lib/brand"
const BrandContext = createContext<BrandConfig>(getBrand(""))
export function BrandProvider({ children }: { children: React.ReactNode }) {
const [brand, setBrand] = useState<BrandConfig | null>(null)
useEffect(() => {
const resolved = getBrand()
setBrand(resolved)
document.title = `${resolved.name} | ${resolved.tagline}`
let icon = document.querySelector<HTMLLinkElement>('link[rel="icon"]')
if (!icon) {
icon = document.createElement("link")
icon.rel = "icon"
document.head.appendChild(icon)
}
icon.href = resolved.favicon
}, [])
if (!brand) return null
return <BrandContext.Provider value={brand}>{children}</BrandContext.Provider>
}
/** The active brand. Every consumer renders after the host has resolved it. */
export function useBrand(): BrandConfig {
return useContext(BrandContext)
}
/** The brand's name as text, for pages whose markup is authored on the server. */
export function BrandName() {
return <>{useBrand().name}</>
}