ESC
NuxtStarterAI logo
Menu
On this page

Tutorials > User Authentication

Ready to get your users on board with Nuxt Starter AI? We've got two built-in ways of user authentication: Magic Links & Google Oauth. You can use both of them at the same time or just use one of them. Take your pick and start!


🌟 Fantastic job completing one of our awesome tutorials! Now, it's time for a high-five! 🙌 To keep going, simply navigate smoothly to the sign-in/sign-up page, just like this:


/components/SignInButton.vue
1<template> 2 <NuxtLink className="btn btn-primary" to="/signin"> 3 Login 4 </NuxtLink> 5</template> 6 7<script lang="ts" setup> 8 9</script> 10<style></style>

In sign in/up pages, the code below takes care of OTP and Google Login out of the box for you in seconds!


/pages/sign-in.vue
1const handleSignup = async (options: { 2 type: string; 3 provider?: Provider; 4}) => { 5 isLoading.value = true; 6 7 try { 8 const { type, provider } = options; 9 const redirectURL = window.location.origin + "/api/auth/callback"; 10 11 if (type === "oauth") { 12 await supabase.auth.signInWithOAuth({ 13 provider, 14 options: { 15 redirectTo: redirectURL, 16 }, 17 }); 18 } else if (type === "magic_link") { 19 await supabase.auth.signInWithOtp({ 20 email, 21 options: { 22 emailRedirectTo: redirectURL, 23 }, 24 }); 25 26 toast.success("Check your emails!"); 27 28 isDisabled.value = true; 29 } 30 } catch (error) { 31 console.log(error); 32 } finally { 33 isLoading.value = false; 34 } 35}; 36