- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library) - Move Convex backend to @otunes/convex for web and mobile reuse - Update web app imports and API routes to use shared package
30 lines
768 B
TypeScript
30 lines
768 B
TypeScript
import { ConvexAuthProvider } from "@convex-dev/auth/react"
|
|
import { ConvexReactClient } from "convex/react"
|
|
import { useMemo, type ReactNode } from "react"
|
|
|
|
import { useServerConfig } from "@/contexts/server-config"
|
|
import { secureStorage } from "@/lib/auth-storage"
|
|
|
|
export function ConvexAppProvider({ children }: { children: ReactNode }) {
|
|
const { config } = useServerConfig()
|
|
|
|
const client = useMemo(() => {
|
|
if (!config) return null
|
|
return new ConvexReactClient(config.convexUrl)
|
|
}, [config?.convexUrl])
|
|
|
|
if (!client || !config) {
|
|
return <>{children}</>
|
|
}
|
|
|
|
return (
|
|
<ConvexAuthProvider
|
|
client={client}
|
|
storage={secureStorage}
|
|
storageNamespace={config.convexUrl}
|
|
>
|
|
{children}
|
|
</ConvexAuthProvider>
|
|
)
|
|
}
|