doug
doug
CCConvex Community
Created by jason on 3/27/2025 in #general
Have you had a chance to explore `Better Auth`
Tried the following approach for server side auth and no luck.
convex/users.ts

import { query } from "./_generated/server";
import { betterAuth } from "./http";

export const getAuth = query({
handler: async (ctx) => {
const user = await betterAuth.getAuthUser(ctx)

return user
}
})
convex/users.ts

import { query } from "./_generated/server";
import { betterAuth } from "./http";

export const getAuth = query({
handler: async (ctx) => {
const user = await betterAuth.getAuthUser(ctx)

return user
}
})
app/page.tsx

import { api } from "@/convex/_generated/api";
import { fetchQuery } from "convex/nextjs";

export default async function Chat() {
const user = await fetchQuery(api.users.getAuth, {});

console.log(user);

return <div>{user?.email ?? "no user"}</div>;
}
app/page.tsx

import { api } from "@/convex/_generated/api";
import { fetchQuery } from "convex/nextjs";

export default async function Chat() {
const user = await fetchQuery(api.users.getAuth, {});

console.log(user);

return <div>{user?.email ?? "no user"}</div>;
}
169 replies
CCConvex Community
Created by jason on 3/27/2025 in #general
Have you had a chance to explore `Better Auth`
Do you think there's any way to get Server Side Auth Working? https://docs.convex.dev/client/react/nextjs/server-rendering#server-side-authentication It's usually await betterAuth.api.getSession() but betterAuth doesn't have access to .api.getSession() We do have access to betterAuth.getAuthUser() but that required ctx to be passed which I believe requires a convex function (client).
169 replies
CCConvex Community
Created by jason on 3/27/2025 in #general
Have you had a chance to explore `Better Auth`
Nope, just followed the directions listed. I did have to reference the example next app in the repository though.
169 replies
CCConvex Community
Created by jason on 3/27/2025 in #general
Have you had a chance to explore `Better Auth`
Got this up an running. Confirmed that Google auth is working in Safari
169 replies
CCConvex Community
Created by doug on 10/29/2024 in #general
Schema analysis paralysis
I just wanted to thank everyone for their thoughts on this. I decided to stop thinking about it and just build out my front end so that I could focus on the UX of the people who will eventually be filling out my forms. Many of you were correct taking this approach. I’m getting a clear picture of what the final schema should look like.
22 replies