-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathauth-client.ts
More file actions
33 lines (29 loc) · 855 Bytes
/
auth-client.ts
File metadata and controls
33 lines (29 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {
customSessionClient,
emailOTPClient,
magicLinkClient,
multiSessionClient,
twoFactorClient,
} from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import type { auth } from "./auth";
// Create a singleton instance with the default configuration
export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL as string,
plugins: [
customSessionClient<typeof auth>(),
multiSessionClient(),
emailOTPClient(),
magicLinkClient(),
twoFactorClient(),
],
});
export const { useSession, signIn, signUp, signOut, getSession } = authClient;
export function useUser() {
const { data, isPending, error } = useSession();
return {
user: data?.user,
isLoading: isPending,
error,
};
}