20 lines
405 B
TypeScript
20 lines
405 B
TypeScript
"use client"
|
|
|
|
import { createAuthClient } from "better-auth/react"
|
|
|
|
let client: ReturnType<typeof createAuthClient> | null = null
|
|
|
|
function initClient() {
|
|
if (typeof window === "undefined") return
|
|
if (!client) {
|
|
client = createAuthClient({
|
|
baseURL: process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
|
|
})
|
|
}
|
|
return client
|
|
}
|
|
|
|
export function getAuth() {
|
|
return initClient()
|
|
}
|