Files
BrowserOS/apps/agent/lib/rpc/getClient.ts
Dani Akash 8657146fb6 fix: reduce suspense boundary depth and improve background color speed (#259)
* fix: move suspense boundary closer to corresponding pages

* fix: pre-resolve the client via singleton to speed up the clientPromise

* feat: apply theme background faster with plain script

* chore: update biome version

* feat: make rpc client persist promise with useMemo and remove loading
text

* fix: replace dvh with vh

* fix: replace dvh with vh in create graph
2026-01-21 23:09:58 +05:30

20 lines
530 B
TypeScript

import type { AppType } from '@browseros/server'
import { hc } from 'hono/client'
import { getAgentServerUrl } from '../browseros/helpers'
export type RpcClient = ReturnType<typeof hc<AppType>>
let clientPromise: Promise<RpcClient> | null = null
export const getClient = (): Promise<RpcClient> => {
if (!clientPromise) {
clientPromise = getAgentServerUrl().then((serverUrl) =>
hc<AppType>(serverUrl),
)
}
return clientPromise
}
// Pre-resolve the client immediately when the module is imported
getClient()