#SignOut not redirecting

7 messages · Page 1 of 1 (latest)

buoyant pilot
#

I ran npm create convex@latest , chose NextJS and setup standard convex auth. Tested and the auth is working fine. The only issue is the SignOut doesn't actually redirect you back to sign in. If you look at the @convex-dev/auth/dist/react/client.js inside AuthProvider the const for SignOut doesn't seem to be doing any redirecting.

const signOut = useCallback(async () => {
        try {
            await client.authenticatedCall("auth:signOut");
        }
        catch (error) {
            // Ignore any errors, they are usually caused by being
            // already signed out, which is ok.
        }
        logVerbose(`signed out, erasing tokens`);
        await setToken({ shouldStore: true, tokens: null });
    }, [setToken, client]);

Does anybody know if I am missing something or if there is a good fix?

marsh riverBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

  • Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
  • Use search.convex.dev to search Docs, Stack, and Discord all at once.
  • Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
  • Avoid tagging staff unless specifically instructed.

Thank you!

buoyant pilot
#

I added a router.push to my user menu after sign out which works. Let me know if anyone knows of a better way.

tawny spade
#

Yep it's not meant to redirect -- just to sign you out. Something like what you described (signOut().then(() => router.push("/signin")) sounds good.

slow narwhal
#

router.push() did nothing for me, but window.location.reload(false); and middleware did the trick.

feedback: I feel that I do prefer having the ability to provide signOut with some options like AuthJS with signOut({ redirectTo: "/" })

shut socket
#

I'm having the same issue, also resorted to window.location.reload I expected reactivity from const { isAuthenticated, isLoading } = useConvexAuth(); but I guess it doesn't work like queries, mutations etc.

stone plover
#

I’ve had a similar issue with signing in and out. I tried using TanStack router navigate() within then() but that wasn’t working either for some reason