signout doesn’t show logged out right away; I have to reload the page to see it.

When I implement signout and click it, it doesn't immediately show the logged-out display; instead, I have to reload the page to see the change. repo - https://github.com/ritiksharmarj/analytics.ritiksharma.me/blob/main/components/app-header.tsx#L77 better auth dir - https://github.com/ritiksharmarj/analytics.ritiksharma.me/tree/main/lib/auth
"use client";

onclick = {async () => {
await signOut({
fetchOptions: {
onSuccess() {
router.push(ROUTES.ROOT);
}
}
})
}}
"use client";

onclick = {async () => {
await signOut({
fetchOptions: {
onSuccess() {
router.push(ROUTES.ROOT);
}
}
})
}}
But it works fine in dev mode
Solution:
if you're fetching the session on the server, you'd have to revlidate to be able to see the updated session (the logged out one).
Jump to solution
3 Replies
Ritik
RitikOP2w ago
@rds Hi Rudro, I've checked your titan repo for this issue and tried signing with google at https://titan.rdsx.dev, and it works fine. But I have the same implementation for signout, and in my case when i click on signout, it doesn't redirect to the root page. https://analytics.ritiksharma.me Surprisingly, it is working fine locally. If you have some time, could you please check the issue at a high level? Hi @bekacru @Ping I've tried everything I can to solve this issue but don't understand what's causing it. Initial thought was that it was a middleware issue but after carefully checking, I don't think so. Surprisingly it works in the local mode. I'd appreciate if you could take a look at this.
Solution
bekacru
bekacru2w ago
if you're fetching the session on the server, you'd have to revlidate to be able to see the updated session (the logged out one).
Ritik
RitikOP2w ago
@bekacru can not we make a new request to the server to refetch the data on signout inside the better auth ?? btw now it's working 🙂

Did you find this page helpful?