Side effect on session changes

Hi, what's the safest way of perfoming a side effect after the user logs out, logs in... when the session changes. Something like that?
const session = authClient.useSession();
$effect(() => {
$session?.user;
doSomething();
}
const session = authClient.useSession();
$effect(() => {
$session?.user;
doSomething();
}
2 Replies
bekacru
bekacru5mo ago
Yes. You can also use the subscribe callback in the session store
Patrick
PatrickOP5mo ago
That's what I was searching for, thanks

Did you find this page helpful?