diff --git a/src/lib/Header.svelte b/src/lib/Header.svelte index b267e45..8649eda 100644 --- a/src/lib/Header.svelte +++ b/src/lib/Header.svelte @@ -2,7 +2,7 @@ import { Avatar, Button, DropdownMenu, Separator } from 'bits-ui'; import { authClient } from './auth-client'; import Image from './Image.svelte'; - import { CircleUser, FolderGit2, User } from '@lucide/svelte'; + import { CircleUser, FolderGit2, Loader2, User } from '@lucide/svelte'; import { goto } from '$app/navigation'; type MockUser = { image: string; @@ -10,8 +10,10 @@ const session = authClient.useSession(); const user = $derived($session.data?.user); + let loading = $state(false); const signIn = async () => { + loading = true; await authClient.signIn.social({ provider: 'github' }); @@ -25,7 +27,11 @@ {#if !user && !$session.isPending} - Sign In + {#if loading} + + {:else} + Sign In + {/if} {:else if user} diff --git a/src/lib/auth-client.ts b/src/lib/auth-client.ts index 4c518f8..a145a8a 100644 --- a/src/lib/auth-client.ts +++ b/src/lib/auth-client.ts @@ -2,6 +2,6 @@ import { jwtClient, adminClient } from 'better-auth/client/plugins'; import { createAuthClient } from 'better-auth/svelte'; export const authClient = createAuthClient({ - baseURL: process.env.BETTER_AUTH_URL!, + baseURL: "http://localhost:5173", plugins: [jwtClient(), adminClient()] });