EMILIANOM
EMILIANOM
CCConvex Community
Created by EMILIANOM on 10/7/2024 in #support-community
Svelte + Clerk | Any example of how to get it working?
Hey, i want to integrate clerk with convex, can anyone share an example of this integration or maybe what steps should i follow and i will it give a try (I'm using lucia but i would like to migrate) https://github.com/lucia-auth/lucia/discussions/1707 (will be deprecated) thanks everyone
7 replies
CCConvex Community
Created by EMILIANOM on 9/26/2024 in #support-community
Convex + Lucia auth + Svelte | Help
Hello i was able to integrate Lucia with convex (thanks to @v and his repo https://github.com/vynxc/lucia-svelte-convex-demo) Now I'm trying to write queries that filter by auth user id, to show only those rows the user owns.
import { queryWithAuth } from './auth/withAuth';

export const get = queryWithAuth({
args: {},
handler: async (ctx) => {
const identity = ctx.userSessionContext?.user;
if (!identity) {
throw new Error('Not authenticated');
}
console.log(identity);

const tasks = await ctx.db
.query('tasks')
// .filter((task) => task.userId === identity._id)
.collect();
return tasks.map((task) => ({ ...task, assigner: 'tom' }));
}
});
import { queryWithAuth } from './auth/withAuth';

export const get = queryWithAuth({
args: {},
handler: async (ctx) => {
const identity = ctx.userSessionContext?.user;
if (!identity) {
throw new Error('Not authenticated');
}
console.log(identity);

const tasks = await ctx.db
.query('tasks')
// .filter((task) => task.userId === identity._id)
.collect();
return tasks.map((task) => ({ ...task, assigner: 'tom' }));
}
});
Identity is null, even if I'm logged in, can anyone check my implementation and help me with some suggestions Thanks everyone Full code: https://github.com/emilianocalzada/convex-lucia-svelte
14 replies