blob: aec3cf4b0a7c6c7813ec9a89d78c2edd9793c079 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { inferAdditionalFields } from 'better-auth/client/plugins';
import { createAuthClient } from 'better-auth/react';
import { toast } from 'sonner';
import type { auth } from '@/server/auth';
// @see https://github.com/better-auth/better-auth/issues/1391
const authClient: ReturnType<typeof createAuthClient> = createAuthClient({
plugins: [inferAdditionalFields<typeof auth>()],
// baseURL: env.BETTER_AUTH_URL,
fetchOptions: {
onError(e) {
if (e.error.status === 429) {
toast.error('Too many requests. Please try again later.');
}
},
},
});
export const signIn: typeof authClient.signIn = authClient.signIn;
export const signOut: typeof authClient.signOut = authClient.signOut;
export const useSession: typeof authClient.useSession = authClient.useSession;
export type User = (typeof authClient.$Infer.Session)['user'];
|