Matt.welson
Matt.welson5mo ago

@convex-dev/auth isn't working with NextJs and Github provider

I had some trouble with my main project, so I started a small project with only the simplest login possible and it still won't work. When I follow the instructions in the doc I end up clicking the login button, approving on Github and then my page reloads, with no session created or anything.
convex/auth.ts
import { convexAuth } from "@convex-dev/auth/server";
import Github from "@auth/core/providers/github";

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Github],
});
convex/auth.ts
import { convexAuth } from "@convex-dev/auth/server";
import Github from "@auth/core/providers/github";

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Github],
});
src/app/page.ts
"use client";

import { useAuthActions } from "@convex-dev/auth/react";
import { Authenticated, AuthLoading, Unauthenticated } from "convex/react";

export default function Home() {
const { signIn } = useAuthActions();

return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<AuthLoading>Loading...</AuthLoading>
<Authenticated>Logged in</Authenticated>
<Unauthenticated>
Not logged in{" "}
<button onClick={() => signIn("github")}>Log in with Github</button>
</Unauthenticated>
</main>
);
}
src/app/page.ts
"use client";

import { useAuthActions } from "@convex-dev/auth/react";
import { Authenticated, AuthLoading, Unauthenticated } from "convex/react";

export default function Home() {
const { signIn } = useAuthActions();

return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<AuthLoading>Loading...</AuthLoading>
<Authenticated>Logged in</Authenticated>
<Unauthenticated>
Not logged in{" "}
<button onClick={() => signIn("github")}>Log in with Github</button>
</Unauthenticated>
</main>
);
}
My convex logs look like the attached image
No description
6 Replies
Matt.welson
Matt.welsonOP5mo ago
One extra confusing part to this: I am getting a user and authAccount for my github account, and an authVerifier - but no sessions are created.
sshader
sshader5mo ago
I tried this out (copied your auth.ts + page.tsx into my own app) and didn't hit issues. To try trouble shooting a little bit, can you confirm you're on the latest version of @convex-dev/auth + convex? Can you double check that all your Convex environment variables look reasonable? (I'll add a screenshot of what's working for me) Do you get the same issue in incognito (or if you clear your local storage on your frontend, and also clear cookies on your happy-animal-123.convex.site domain)
sshader
sshader5mo ago
Here are the variables I have set
No description
Matt.welson
Matt.welsonOP5mo ago
Oh I had deleted all local storage but I didn’t think about the .convex.site domain - I’ll go and make sure those are all gone and try another browser/incognito too. Thanks for the tips! The versions are all freshly installed by bun, and the variables all look good to me. Okay, I have tried in Chrome and that works, no luck with Safari at all but that lets me crack on anyway. Safari didn't work even on "private browser"
sshader
sshader5mo ago
Oh interesting that it seems to be browser specific! I was trying in Chrome. Let's see if I hit this in Safari Ok I can reproduce this in Safari -- I'll dig into what's happening there. Thanks for the bug report! The Safari issue should be fixed on the latest Convex Auth version (0.0.63)!
Matt.welson
Matt.welsonOP5mo ago
Just to confirm, that update is working for me, thanks!

Did you find this page helpful?