Skip to content

Commit 3485cd4

Browse files
Baroshemivasilovsaltcod
authored
Docs/UI library vue nuxt password auth (supabase#39405)
* docs: ui library password auth vue * docs: ui library password auth nuxt * Fix a pnpm-lock conflict. * Adjust paths * Fix import path * Rebuild * docs: remove shadcn-vue package * Fix the pnpm-lock. --------- Co-authored-by: Ivan Vasilov <[email protected]> Co-authored-by: Terry Sutton <[email protected]>
1 parent 63e03a1 commit 3485cd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1880
-21
lines changed

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
"graphiql": "^4.0.2",
154154
"openapi-types": "^12.1.3",
155155
"postcss": "^8.5.3",
156+
"tailwindcss": "catalog:",
156157
"shiki": "^3.2.1",
157158
"shx": "^0.4.0",
158159
"simple-git": "^3.24.0",

apps/ui-library/config/docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const componentPages: SidebarNavGroup = {
6161
},
6262
{
6363
title: 'Password-Based Auth',
64-
supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react'],
64+
supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react', 'vue', 'nuxtjs'],
6565
href: '/docs/nextjs/password-based-auth',
6666
items: [],
6767
commandItemLabel: 'Password-Based Auth',
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: Password-based Authentication
3+
description: Password-based authentication block for Nuxt.js
4+
---
5+
6+
<BlockPreview name="password-based-auth/auth/sign-up" />
7+
8+
## Installation
9+
10+
<BlockItem
11+
name="password-based-auth-nuxtjs"
12+
description="All needed components for the password based auth flow"
13+
/>
14+
15+
## Folder structure
16+
17+
This block assumes that you have already installed a Supabase client for Nuxt from the previous step.
18+
19+
<RegistryBlock itemName="password-based-auth-nuxtjs" />
20+
21+
## Usage
22+
23+
Once you install the block in your Next.js project, you'll get all the necessary pages and components to set up a password-based authentication flow.
24+
25+
### Getting started
26+
27+
After installing the block, you'll have the following environment variables in your `.env.local` file:
28+
29+
```env
30+
NUXT_PUBLIC_SUPABASE_URL=
31+
NUXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY=
32+
```
33+
34+
- If you're using supabase.com, you can find these values in the [Connect modal](https://supabase.com/dashboard/project/_?showConnect=true) under App Frameworks or in your project's [API settings](https://supabase.com/dashboard/project/_/settings/api).
35+
36+
- If you're using a local instance of Supabase, you can find these values by running `supabase start` or `supabase status` (if you already have it running).
37+
38+
### Adding email templates
39+
40+
1. Add an [email template for sign-up](https://supabase.com/dashboard/project/_/auth/templates) to the Supabase project. Your signup email template should contain at least the following HTML:
41+
42+
```html
43+
<h2>Confirm your signup</h2>
44+
45+
<p>Follow this link to confirm your user:</p>
46+
<p>
47+
<a
48+
href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=email&next={{ .RedirectTo }}"
49+
>Confirm your email</a
50+
>
51+
</p>
52+
```
53+
54+
For detailed instructions on how to configure your email templates, including the use of variables like `{{ .SiteURL }}`,`{{ .TokenHash }}`, and `{{ .RedirectTo }}`, refer to our [Email Templates guide](https://supabase.com/docs/email-templates).
55+
56+
1. Add an [email template for reset password](https://supabase.com/dashboard/project/_/auth/templates) to the Supabase project. Your reset password email template should contain at least the following HTML:
57+
58+
```html
59+
<h2>Reset Password</h2>
60+
61+
<p>Follow this link to reset the password for your user:</p>
62+
<p>
63+
<a
64+
href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=recovery&next={{ .RedirectTo }}"
65+
>Reset Password</a
66+
>
67+
</p>
68+
```
69+
70+
### Setting up routes and redirect URLs
71+
72+
1. Set the site URL in the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings in the Supabase Dashboard.
73+
1. Set up the Next.js route that users will visit to reset or update their password. Go to the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings and add the `forgot-password` route to the list of Redirect URLs. It should look something like: `http://example.com/auth/forgot-password`.
74+
75+
1. Update the redirect paths in `login-form.vue` and `update-password-form.vue` components to point to the logged-in routes in your app. Our examples use `/protected`, but you can set this to whatever fits your app.
76+
77+
## Further reading
78+
79+
- [Password-based authentication (PKCE flow)](https://supabase.com/docs/guides/auth/passwords?queryGroups=flow&flow=pkce)
80+
- [Authentication error codes](https://supabase.com/docs/guides/auth/debugging/error-codes)
81+
- [Email templates](https://supabase.com/docs/guides/auth/auth-email-templates)
82+
- [Email templates for local development](https://supabase.com/docs/guides/local-development/customizing-email-templates)
83+
- [Custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Password-based Authentication
3+
description: Password-based authentication block for Vue Single Page Applications
4+
---
5+
6+
<BlockPreview name="password-based-auth/auth/sign-up" />
7+
8+
## Installation
9+
10+
<BlockItem
11+
name="password-based-auth-vue"
12+
description="All needed components for the password based auth flow"
13+
/>
14+
15+
## Folder structure
16+
17+
This block assumes that you have already installed a Supabase client for Vue from the previous step.
18+
19+
<RegistryBlock itemName="password-based-auth-vue" />
20+
21+
## Usage
22+
23+
Once you install the block in your Vue project, you'll get all the necessary components to set up a password-based authentication flow.
24+
25+
### Getting started
26+
27+
After installing the block, you'll have the following environment variables in your `.env.local` file:
28+
29+
```env
30+
VITE_SUPABASE_URL=
31+
VITE_SUPABASE_PUBLISHABLE_OR_ANON_KEY=
32+
```
33+
34+
- If you're using supabase.com, you can find these values in the [Connect modal](https://supabase.com/dashboard/project/_?showConnect=true&tab=frameworks&framework=vuejs&using=supabasejs) under App Frameworks or in your project's [API keys](https://supabase.com/dashboard/project/_/settings/api-keys).
35+
36+
- If you're using a local instance of Supabase, you can find these values by running `supabase start` or `supabase status` (if you already have it running).
37+
38+
### Setting up routes and redirect URLs
39+
40+
1. Set the site URL in the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings in the Supabase Dashboard.
41+
1. Set up the route users will visit to reset or update their password. Go to the [URL Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) settings and add the `forgot-password` route to the list of Redirect URLs. It should look something like: `http://example.com/auth/forgot-password`.
42+
1. Update the redirect paths in `login.vue` and `update-password.vue` components to point to the logged-in routes in your app. Our examples use `/protected`, but you can set this to whatever fits your app.
43+
44+
1. Add the following code in the authenticated route to redirect to login if the user is unauthenticated.
45+
46+
```vue
47+
<script setup lang="ts">
48+
import { onMounted } from 'vue'
49+
import { createClient } from '@/lib/supabase/client'
50+
51+
onMounted(async () => {
52+
const client = createClient()
53+
54+
const { error } = await client.auth.getUser()
55+
56+
if (error) {
57+
location.href = '/login'
58+
}
59+
})
60+
</script>
61+
62+
<template>
63+
<div>Authenticated page</div>
64+
</template>
65+
```
66+
67+
Additionally, you could utilize the Navigation Guards from `vue-router` explained [here](https://router.vuejs.org/guide/advanced/navigation-guards#Global-Before-Guards).
68+
69+
## Further reading
70+
71+
- [Password-based authentication (implicit flow)](https://supabase.com/docs/guides/auth/passwords?queryGroups=flow&flow=implicit)
72+
- [Authentication error codes](https://supabase.com/docs/guides/auth/debugging/error-codes)
73+
- [Email templates](https://supabase.com/docs/guides/auth/auth-email-templates)
74+
- [Email templates for local development](https://supabase.com/docs/guides/local-development/customizing-email-templates)
75+
- [Custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp)

apps/ui-library/public/llms.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Supabase UI Library
2-
Last updated: 2025-10-15T07:54:48.550Z
2+
Last updated: 2025-11-06T16:46:13.786Z
33

44
## Overview
55
Library of components for your project. The components integrate with Supabase and are shadcn compatible.
@@ -33,6 +33,8 @@ Library of components for your project. The components integrate with Supabase a
3333
- Social authentication block for Next.js
3434
- [Supabase Client Libraries](https://supabase.com/ui/docs/nuxtjs/client)
3535
- Supabase client for Nuxt.js
36+
- [Password-based Authentication](https://supabase.com/ui/docs/nuxtjs/password-based-auth)
37+
- Password-based authentication block for Nuxt.js
3638
- [Platform Kit](https://supabase.com/ui/docs/platform/platform-kit)
3739
- The easiest way to build platforms on top of Supabase
3840
- [Supabase Client Libraries](https://supabase.com/ui/docs/react-router/client)
@@ -85,3 +87,5 @@ Library of components for your project. The components integrate with Supabase a
8587
- Social authentication block for Tanstack Start
8688
- [Supabase Client Libraries](https://supabase.com/ui/docs/vue/client)
8789
- Supabase client for Vue Single Page Applications
90+
- [Password-based Authentication](https://supabase.com/ui/docs/vue/password-based-auth)
91+
- Password-based authentication block for Vue Single Page Applications

0 commit comments

Comments
 (0)