Add beenvoice mobile companion app with full dark mode support.
Expo app with dashboard, time clock, invoices, and settings — native tabs, glass UI, theme-aware components, and iOS Live Activities. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { expoClient } from "@better-auth/expo/client";
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
import * as SecureStore from "expo-secure-store";
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
useMemo,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
type AuthClient = ReturnType<typeof createAuthClient>;
|
||||
|
||||
const AuthContext = createContext<AuthClient | null>(null);
|
||||
|
||||
export function AuthProvider({
|
||||
apiUrl,
|
||||
storagePrefix,
|
||||
children,
|
||||
}: {
|
||||
apiUrl: string;
|
||||
storagePrefix: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const client = useMemo(
|
||||
() =>
|
||||
createAuthClient({
|
||||
baseURL: apiUrl,
|
||||
plugins: [
|
||||
expoClient({
|
||||
scheme: "beenvoice",
|
||||
storagePrefix,
|
||||
storage: SecureStore,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
[apiUrl, storagePrefix],
|
||||
);
|
||||
|
||||
return <AuthContext.Provider value={client}>{children}</AuthContext.Provider>;
|
||||
}
|
||||
|
||||
export function useAuthClient() {
|
||||
const client = useContext(AuthContext);
|
||||
if (!client) throw new Error("useAuthClient must be used within AuthProvider");
|
||||
return client;
|
||||
}
|
||||
|
||||
export function useSession() {
|
||||
return useAuthClient().useSession();
|
||||
}
|
||||
Reference in New Issue
Block a user