Files
zeekay 692263e5ff Dispatch — newsletter archive & signup
A real Hanzo-stack starter template: public newsprint masthead + subscribe,
signed-in archive/issue reader, and a Studio composer over org-scoped Base
collections (issues + subscribers). Vite + React 19 + @hanzo/gui + @hanzo/iam
+ @hanzo/base; PKCE against hanzo.id; provisioned from schema.sql.

tsc + vite build green.
2026-07-21 10:34:56 -07:00

35 lines
1.3 KiB
TypeScript

import { useMemo, type ReactNode } from 'react'
import { GuiProvider } from '@hanzo/gui'
import { IamProvider, useIam } from '@hanzo/iam/react'
import { BaseProvider } from '@hanzo/base/react'
import guiConfig from './gui.config'
import { iamConfig } from './iam.config'
import { baseAs } from './lib/base'
/**
* Bridges the IAM session into Hanzo Base: builds a BaseClient carrying the
* signed-in user's IAM token and re-creates it whenever the token changes, so
* every useQuery/useMutation under it is scoped to that user's org.
*/
function BaseBridge({ children }: { children: ReactNode }) {
const { accessToken } = useIam()
const client = useMemo(() => baseAs(accessToken), [accessToken])
return <BaseProvider client={client}>{children}</BaseProvider>
}
/**
* The one provider stack, in the order the canonical Hanzo surfaces ship:
* gui (design system) → IAM (identity) → Base (data). Dispatch fixes the light
* theme for its newsprint palette; swap `defaultTheme` or wrap subtrees in
* <Theme> to change it.
*/
export function Providers({ children }: { children: ReactNode }) {
return (
<GuiProvider config={guiConfig} defaultTheme="light">
<IamProvider config={iamConfig}>
<BaseBridge>{children}</BaseBridge>
</IamProvider>
</GuiProvider>
)
}