Files
better-auth/demo/nextjs/lib/auth-client.ts
Bereket Engida 7c728248dc fix: delete user should respect freshAge config (#3075)
* fix: delete user needs to enforced through fresh age

* cleanup

* cleanup
2025-06-18 21:20:52 -07:00

56 lines
1.0 KiB
TypeScript

import { createAuthClient } from "better-auth/react";
import {
organizationClient,
passkeyClient,
twoFactorClient,
adminClient,
multiSessionClient,
oneTapClient,
oidcClient,
genericOAuthClient,
} from "better-auth/client/plugins";
import { toast } from "sonner";
import { stripeClient } from "@better-auth/stripe/client";
export const client = createAuthClient({
plugins: [
organizationClient(),
twoFactorClient({
onTwoFactorRedirect() {
window.location.href = "/two-factor";
},
}),
passkeyClient(),
adminClient(),
multiSessionClient(),
oneTapClient({
clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID!,
promptOptions: {
maxAttempts: 1,
},
}),
oidcClient(),
genericOAuthClient(),
stripeClient({
subscription: true,
}),
],
fetchOptions: {
onError(e) {
if (e.error.status === 429) {
toast.error("Too many requests. Please try again later.");
}
},
},
});
export const {
signUp,
signIn,
signOut,
useSession,
organization,
useListOrganizations,
useActiveOrganization,
} = client;