Social Auth flow for Nuxt and Supabase
supabase-library/social-auth-nuxtjsFreeBlock
Social Auth flow for Nuxt and Supabase
Install it
npx shadcn@latest add https://raw.githubusercontent.com/supabase/supabase/master/apps/ui-library/public/r/social-auth-nuxtjs.jsonSource
1<script setup lang="ts">2import { ref } from "vue"3import { createClient } from "@/lib/supabase/client"4import { cn } from "@/lib/utils"56import { Button } from "@/components/ui/button.vue"7import {8 Card,9 CardContent,10 CardDescription,11 CardHeader,12 CardTitle,13} from "@/components/ui/card.vue"1415// Reactive state16const error = ref<string | null>(null)17const isLoading = ref(false)1819// GitHub OAuth login handler20const handleSocialLogin = async (e: Event) => {21 e.preventDefault()22 const supabase = createClient()23 isLoading.value = true24 error.value = null2526 try {27 const { error: supabaseError } = await supabase.auth.signInWithOAuth({28 provider: "github",29 options: {30 redirectTo: `${window.location.origin}/api/routes/oauth?next=/protected`,31 },32 })3334 if (supabaseError) throw supabaseError35 } catch (err: unknown) {36 error.value = err instanceof Error ? err.message : "An error occurred"37 isLoading.value = false38 }39}40</script>4142<template>43 <div :class="cn('flex flex-col gap-6')">44 <Card>45 <CardHeader>46 <CardTitle class="text-2xl">Welcome!</CardTitle>47 <CardDescription>Sign in to your account to continue</CardDescription>48 </CardHeader>49 <CardContent>50 <form @submit="handleSocialLogin">51 <div class="flex flex-col gap-6">52 <p v-if="error" class="text-sm text-destructive-500">{{ error }}</p>53 <Button type="submit" class="w-full" :disabled="isLoading">54 {{ isLoading ? "Logging in..." : "Continue with GitHub" }}55 </Button>56 </div>57 </form>58 </CardContent>59 </Card>60 </div>61</template>
What it pulls in
npm packages
Other registry items
Files it writes
More from Supabase Library
All 60 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Current User Avatarcurrent-user-avatar-nuxtjs | Supabase Library | Blocks | Free | 1 dep · 3 files | |
| Current User Avatarcurrent-user-avatar-vue | Supabase Library | Blocks | Free | 1 dep · 3 files | |
| Dropzone (File Upload) for Nuxt and Supabasedropzone-nuxtjs | Supabase Library | Blocks | Free | 3 deps · 4 files | |
| Dropzone (File Upload) for Vue and Supabasedropzone-vue | Supabase Library | Blocks | Free | 3 deps · 4 files | |
| Infinite Query Hookinfinite-query-hook | Supabase Library | Blocks | Free | 2 deps | |
| Password Based Auth flow for Nextjs and Supabasepassword-based-auth-nextjs | Supabase Library | Blocks | Free | 2 deps · 17 files | |
| Password Based Auth flow for Nuxt.js and Supabasepassword-based-auth-nuxtjs | Supabase Library | Blocks | Free | 2 deps · 12 files | |
| Password Based Auth flow for React and Supabasepassword-based-auth-react | Supabase Library | Blocks | Free | 1 dep · 5 files |
