The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Merge pull request #11928 from icarusgk/patch-1
dng8e769ffbdcd2
diff --cc apps/docs/pages/guides/getting-started/tutorials/with-vue-3.mdxindex b40659546fe,639176f8cdd..0420638cb95--- a/apps/docs/pages/guides/getting-started/tutorials/with-vue-3.mdx+++ b/apps/docs/pages/guides/getting-started/tutorials/with-vue-3.mdx@@@ -66,32 -66,32 +66,32 @@@ Optionally, update [src/style.css](http### Set up a Login component-Let's set up a Vue component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.+Set up an `src/components/Auth.vue` component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords.- ```html title=/src/components/Auth.vue+ ```vue title=/src/components/Auth.vue<script setup>- import { ref } from 'vue'- import { supabase } from '../supabase'-- const loading = ref(false)- const email = ref('')-- const handleLogin = async () => {- try {- loading.value = true- const { error } = await supabase.auth.signInWithOtp({- email: email.value,- })- if (error) throw error- alert('Check your email for the login link!')- } catch (error) {- if (error instanceof Error) {- alert(error.message)- }- } finally {- loading.value = false+ import { ref } from 'vue'+ import { supabase } from '../supabase'++ const loading = ref(false)+ const email = ref('')++ const handleLogin = async () => {+ try {+ loading.value = true+ const { error } = await supabase.auth.signInWithOtp({+ email: email.value,+ })+ if (error) throw error+ alert('Check your email for the login link!')+ } catch (error) {+ if (error instanceof Error) {+ alert(error.message)}+ } finally {+ loading.value = false}+ }</script><template>@@@ -118,84 -118,84 +118,84 @@@### Account pageAfter a user is signed in we can allow them to edit their profile details and manage their account.-Let's create a new component for that called `Account.vue`.+Create a new `src/components/Account.vue` component to handle this.- ```html title=src/components/Account.vue+ ```vue title=src/components/Account.vue<script setup>- import { supabase } from '../supabase'- import { onMounted, ref, toRefs } from 'vue'-- const props = defineProps(['session'])- const { session } = toRefs(props)-- const loading = ref(true)- const username = ref('')- const website = ref('')- const avatar_url = ref('')-- onMounted(() => {- getProfile()- })-- async function getProfile() {- try {- loading.value = true- const { user } = session.value-- let { data, error, status } = await supabase- .from('profiles')- .select(`username, website, avatar_url`)- .eq('id', user.id)- .single()-- if (error && status !== 406) throw error-- if (data) {- username.value = data.username- website.value = data.website- avatar_url.value = data.avatar_url- }- } catch (error) {- alert(error.message)- } finally {- loading.value = false+ import { supabase } from '../supabase'+ import { onMounted, ref, toRefs } from 'vue'++ const props = defineProps(['session'])+ const { session } = toRefs(props)++ const loading = ref(true)+ const username = ref('')+ const website = ref('')+ const avatar_url = ref('')++ onMounted(() => {+ getProfile()+ })++ async function getProfile() {+ try {+ loading.value = true+ const { user } = session.value++ let { data, error, status } = await supabase+ .from('profiles')+ .select(`username, website, avatar_url`)+ .eq('id', user.id)+ .single()++ if (error && status !== 406) throw error++ if (data) {+ username.value = data.username+ website.value = data.website+ avatar_url.value = data.avatar_url}+ } catch (error) {+ alert(error.message)+ } finally {+ loading.value = false}+ }- async function updateProfile() {- try {- loading.value = true- const { user } = session.value-- const updates = {- id: user.id,- username: username.value,- website: website.value,- avatar_url: avatar_url.value,- updated_at: new Date(),- }+ async function updateProfile() {+ try {+ loading.value = true+ const { user } = session.value++ const updates = {+ id: user.id,+ username: username.value,+ website: website.value,+ avatar_url: avatar_url.value,+ updated_at: new Date(),+ }- let { error } = await supabase.from('profiles').upsert(updates)+ let { error } = await supabase.from('profiles').upsert(updates)- if (error) throw error- } catch (error) {- alert(error.message)- } finally {- loading.value = false- }+ if (error) throw error+ } catch (error) {+ alert(error.message)+ } finally {+ loading.value = false}+ }- async function signOut() {- try {- loading.value = true- let { error } = await supabase.auth.signOut()- if (error) throw error- } catch (error) {- alert(error.message)- } finally {- loading.value = false- }+ async function signOut() {+ try {+ loading.value = true+ let { error } = await supabase.auth.signOut()+ if (error) throw error+ } catch (error) {+ alert(error.message)+ } finally {+ loading.value = false}+ }</script><template>@@@ -277,58 -277,58 +277,58 @@@ Every Supabase project is configured wi### Create an upload widget-Let's create an avatar for the user so that they can upload a profile photo. We can start by creating a new component:+Create a new `src/components/Avatar.vue` component that allows users to upload profile photos:- ```html title=src/components/Avatar.vue+ ```vue title=src/components/Avatar.vue<script setup>- import { ref, toRefs, watch } from 'vue'- import { supabase } from '../supabase'-- const prop = defineProps(['path', 'size'])- const { path, size } = toRefs(prop)-- const emit = defineEmits(['upload', 'update:path'])- const uploading = ref(false)- const src = ref('')- const files = ref()-- const downloadImage = async () => {- try {- const { data, error } = await supabase.storage.from('avatars').download(path.value)- if (error) throw error- src.value = URL.createObjectURL(data)- } catch (error) {- console.error('Error downloading image: ', error.message)- }+ import { ref, toRefs, watch } from 'vue'+ import { supabase } from '../supabase'++ const prop = defineProps(['path', 'size'])+ const { path, size } = toRefs(prop)++ const emit = defineEmits(['upload', 'update:path'])+ const uploading = ref(false)+ const src = ref('')+ const files = ref()++ const downloadImage = async () => {+ try {+ const { data, error } = await supabase.storage.from('avatars').download(path.value)+ if (error) throw error+ src.value = URL.createObjectURL(data)+ } catch (error) {+ console.error('Error downloading image: ', error.message)}+ }- const uploadAvatar = async (evt) => {- files.value = evt.target.files- try {- uploading.value = true- if (!files.value || files.value.length === 0) {- throw new Error('You must select an image to upload.')- }+ const uploadAvatar = async (evt) => {+ files.value = evt.target.files+ try {+ uploading.value = true+ if (!files.value || files.value.length === 0) {+ throw new Error('You must select an image to upload.')+ }- const file = files.value[0]- const fileExt = file.name.split('.').pop()- const filePath = `${Math.random()}.${fileExt}`+ const file = files.value[0]+ const fileExt = file.name.split('.').pop()+ const filePath = `${Math.random()}.${fileExt}`- let { error: uploadError } = await supabase.storage.from('avatars').upload(filePath, file)+ let { error: uploadError } = await supabase.storage.from('avatars').upload(filePath, file)- if (uploadError) throw uploadError- emit('update:path', filePath)- emit('upload')- } catch (error) {- alert(error.message)- } finally {- uploading.value = false- }+ if (uploadError) throw uploadError+ emit('update:path', filePath)+ emit('upload')+ } catch (error) {+ alert(error.message)+ } finally {+ uploading.value = false}+ }- watch(path, () => {- if (path.value) downloadImage()- })+ watch(path, () => {+ if (path.value) downloadImage()+ })</script><template>@@@ -361,12 -361,12 +361,12 @@@### Add the new widget-And then we can add the widget to the Account page:+And then we can add the widget to the Account page in `src/components/Account.vue`:- ```html title=src/components/Account.vue+ ```vue title=src/components/Account.vue<script>- // Import the new component- import Avatar from './Avatar.vue'+ // Import the new component+ import Avatar from './Avatar.vue'</script><template>