@daveyplate/better-auth-persistent
Version:
Persistent session management for Better Auth
16 lines (11 loc) • 496 B
text/typescript
import { $authClient } from "./stores/auth-client"
import { $persistentSession } from "./stores/persistent-session"
import type { AnyAuthClient } from "./types/any-auth-client"
import type { AuthClient } from "./types/auth-client"
export function initPersistSession(authClient: AnyAuthClient) {
if ($authClient.get()) return
$authClient.set(authClient as AuthClient)
const sessionResult = $persistentSession.get()
if (!sessionResult.data) return
sessionResult.refetch()
}