Social Auth flow for TanStack and Supabase
supabase-ui-library/social-auth-tanstackUnverifiedBlock
Social Auth flow for TanStack and Supabase
Install it
npx shadcn@latest add https://raw.githubusercontent.com/aimultiple-benchmark/supabase-bench-cr-2/main/apps/ui-library/public/r/social-auth-tanstack.jsonSource
1import { useState } from 'react'23import { cn } from '@/lib/utils'4import { createClient } from '@/registry/default/clients/tanstack/lib/supabase/client'5import { Button } from '@/registry/default/components/ui/button'6import {7 Card,8 CardContent,9 CardDescription,10 CardHeader,11 CardTitle,12} from '@/registry/default/components/ui/card'1314export function LoginForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {15 const [error, setError] = useState<string | null>(null)16 const [isLoading, setIsLoading] = useState(false)1718 const handleSocialLogin = async (e: React.FormEvent) => {19 e.preventDefault()20 const supabase = createClient()21 setIsLoading(true)22 setError(null)2324 try {25 const { error } = await supabase.auth.signInWithOAuth({26 provider: 'github',27 options: {28 redirectTo: `${window.location.origin}/auth/oauth?next=/protected`,29 },30 })3132 if (error) throw error33 } catch (error: unknown) {34 setError(error instanceof Error ? error.message : 'An error occurred')35 setIsLoading(false)36 }37 }3839 return (40 <div className={cn('flex flex-col gap-6', className)} {...props}>41 <Card>42 <CardHeader>43 <CardTitle className="text-2xl">Welcome!</CardTitle>44 <CardDescription>Sign in to your account to continue</CardDescription>45 </CardHeader>46 <CardContent>47 <form onSubmit={handleSocialLogin}>48 <div className="flex flex-col gap-6">49 {error && <p className="text-sm text-destructive-500">{error}</p>}50 <Button type="submit" className="w-full" disabled={isLoading}>51 {isLoading ? 'Logging in...' : 'Continue with GitHub'}52 </Button>53 </div>54 </form>55 </CardContent>56 </Card>57 </div>58 )59}
What it pulls in
npm packages
Other registry items
Files it writes
More from Supabase UI Library
All 37 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Current User Avatarcurrent-user-avatar-nuxtjs | Supabase UI Library | Blocks | Unverified | 1 dep · 3 files | |
| Current User Avatarcurrent-user-avatar-vue | Supabase UI Library | Blocks | Unverified | 1 dep · 3 files | |
| Dropzone (File Upload) for Nuxt and Supabasedropzone-nuxtjs | Supabase UI Library | Blocks | Unverified | 3 deps · 4 files | |
| Dropzone (File Upload) for Vue and Supabasedropzone-vue | Supabase UI Library | Blocks | Unverified | 3 deps · 4 files | |
| Infinite Query Hookinfinite-query-hook | Supabase UI Library | Blocks | Unverified | 2 deps | |
| Password Based Auth flow for Nextjs and Supabasepassword-based-auth-nextjs | Supabase UI Library | Blocks | Unverified | 2 deps · 17 files | |
| Password Based Auth flow for Nuxt.js and Supabasepassword-based-auth-nuxtjs | Supabase UI Library | Blocks | Unverified | 2 deps · 12 files | |
| Password Based Auth flow for React and Supabasepassword-based-auth-react | Supabase UI Library | Blocks | Unverified | 1 dep · 5 files |
