I am running into some issues with auth using Convex Svelte. I was directed here from the Convex Discord. I feel like I am so close, so thank you for checking this out. This works:
Convex connection to the backend works
Clerk integration (giving me a valid JWT in te below code), I am not married to Clerk, I just want something to work
The line containing INSIDE setAuth is called, and shown in the log in Chrome
...however...:
I cannot see the JWT in the network payload (not quite sure where to look, have looked at the WS-connection)
Identity on the server is null
My "main" file looks like this:
<script lang="ts">
import { PUBLIC_CONVEX_URL } from '$env/static/public';
import { setupConvex, useConvexClient } from 'convex-svelte';
import { SignIn, useClerkContext } from 'svelte-clerk';
import * as Sidebar from '$lib/components/ui/sidebar/index.js';
import AppSidebar from '$lib/components/app-sidebar.svelte';
import '../app.css';
let { children } = $props();
const ctx = useClerkContext();
const isLoaded = $derived(ctx.isLoaded);
const user = $derived(ctx.user);
setupConvex(PUBLIC_CONVEX_URL);
$effect.pre(() => {
const client = useConvexClient();
client.setAuth(async () => {
const token = await ctx.session?.getToken();
console.log('INSIDE setAuth', token);
return token;
});
});
</script>
This code is created from a discussion on Discord #general. As I mentioned above the console.log-line outputs a valid JWT.
I am running into some issues with auth using Convex Svelte. I was directed here from the Convex Discord. I feel like I am so close, so thank you for checking this out. This works:
INSIDE setAuth
is called, and shown in the log in Chrome...however...:
My "main" file looks like this:
This code is created from a discussion on Discord #general. As I mentioned above the
console.log
-line outputs a valid JWT.Thanks!