From 002de462ff8de67e221a7420860104a48eedbd51 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 18 Oct 2022 23:12:47 +0000 Subject: [PATCH] chore: update vue 3 quickstart guide --- apps/reference/docs/guides/with-vue-3.mdx | 497 +++++++++------------- 1 file changed, 199 insertions(+), 298 deletions(-) diff --git a/apps/reference/docs/guides/with-vue-3.mdx b/apps/reference/docs/guides/with-vue-3.mdx index 06b7f9e0617..49ce6b3739b 100644 --- a/apps/reference/docs/guides/with-vue-3.mdx +++ b/apps/reference/docs/guides/with-vue-3.mdx @@ -24,7 +24,7 @@ By the end of this guide you'll have an app which allows users to login and upda ### GitHub -Whenever you get stuck at any point, take a look at [this repo](https://github.com/zernonia/supabase-vue-3). +Whenever you get stuck at any point, take a look at [this repo](https://github.com/supabase/examples/tree/main/supabase-js-v2/user-management/vue3-user-management). ## Project set up @@ -182,102 +182,141 @@ const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY export const supabase = createClient(supabaseUrl, supabaseAnonKey) ``` -And one optional step is to update the CSS file `src/assets/main.css` to make the app look nice. -You can find the full contents of this file [here](https://raw.githubusercontent.com/supabase/examples/main/supabase-js-v2/user-management/react-user-management/src/index.css). - -```javascript title="src/main.js" -import { createApp } from 'vue' -import App from './App.vue' -import './assets/main.css' - -createApp(App).mount('#app') -``` +Optionally, update [src/style.css](https://raw.githubusercontent.com/supabase/examples/main/supabase-js-v2/user-management/vue3-user-management/src/style.css) to style the app. ### 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. ```html title="/src/components/Auth.vue" + + - - -``` - -### User store - -To access the user information in other places, we use a reactive store. Create a new file called `store.js` and utilize Vue 3 `reactive` functionalities. - -```javascript title="src/store.js" -import { reactive } from 'vue' - -export const store = reactive({ - user: {}, -}) ``` ### Account page After 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 `Profile.vue`. +Let's create a new component for that called `Account.vue`. + +```html title="src/components/Account.vue" + -```html title="src/components/Profile.vue" - - ``` ### Launch! @@ -403,37 +346,31 @@ Let's create a new component for that called `Profile.vue`. Now that we have all the components in place, let's update `App.vue`: ```html title="src/App.vue" + + - - ``` Once that's done, run this in a terminal window: @@ -442,7 +379,7 @@ Once that's done, run this in a terminal window: npm run dev ``` -And then open the browser to [localhost:3000](http://localhost:3000) and you should see the completed app. +And then open the browser to [localhost:5173](http://localhost:5173) and you should see the completed app. ![Supabase Vue 3](/img/supabase-vue-3-demo.png) @@ -455,132 +392,96 @@ Every Supabase project is configured with [Storage](/docs/guides/storage) for ma Let's create an avatar for the user so that they can upload a profile photo. We can start by creating a new component: ```html title="src/components/Avatar.vue" + + - - ``` ### Add the new widget And then we can add the widget to the Account page: -```html title="src/Profile.vue" +```html title="src/components/Account.vue" + + - - ``` ## Next steps