© 2026 Hedgehog Software, LLC
import { env } from "@/env"; import { createAuthClient } from "better-auth/react"; import { magicLinkClient } from "better-auth/client/plugins"; export const authClient = createAuthClient({ baseURL: env.NEXT_PUBLIC_BETTER_AUTH_URL, plugins: [magicLinkClient()], fetchOptions: { onSuccess: (ctx) => { console.debug("Auth client response headers", ctx.response.headers); const authToken = ctx.response.headers.get("set-auth-token"); // get the token from the response headers // Store the token securely (e.g., in localStorage) if (authToken) { console.debug("🔑 Auth Token Set", authToken); localStorage.setItem("bearer_token", authToken); } }, }, }); export const { signIn, signUp, useSession, signOut, magicLink } = authClient;
Auth client response headers