Skip to content

Commit 24a07f0

Browse files
authored
docs(studio): apply notion like editor changes
1 parent db8c102 commit 24a07f0

9 files changed

+65
-33
lines changed

docs/content/2.get-started.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ Add `@nuxtjs/supabase` dev dependency to your project:
2020
```bash [pnpm]
2121
pnpm add -D @nuxtjs/supabase
2222
```
23+
2324
```bash [yarn]
2425
yarn add --dev @nuxtjs/supabase
2526
```
27+
2628
```bash [NPM]
2729
npm install @nuxtjs/supabase --save-dev
2830
```
31+
2932
```bash [bun]
3033
bun add -D @nuxtjs/supabase
3134
```
@@ -41,7 +44,7 @@ export default defineNuxtConfig({
4144

4245
Add `SUPABASE_URL` and `SUPABASE_KEY` to the `.env`:
4346

44-
```zsh [env]
47+
```bash [env]
4548
SUPABASE_URL="https://example.supabase.co"
4649
SUPABASE_KEY="<your_key>"
4750
```
@@ -65,7 +68,7 @@ export default defineNuxtConfig({
6568
6669
### `url`
6770
68-
Default: `process.env.SUPABASE_URL` (ex: https://example.supabase.co)
71+
Default: `process.env.SUPABASE_URL` (ex: <https://example.supabase.co>)
6972
7073
The unique Supabase URL which is supplied when you create a new project in your project dashboard.
7174
@@ -81,14 +84,12 @@ Default: `process.env.SUPABASE_SERVICE_KEY`
8184
8285
Supabase 'service role key', has super admin rights and can bypass your Row Level Security.
8386
84-
8587
### `redirect`
8688
8789
Default: `true`
8890
8991
Redirect automatically to the configured login page if a non authenticated user is trying to access a guarded. You can disable all redirects by setting this option to false.
9092
91-
9293
### `redirectOptions`
9394
9495
Default:
@@ -101,10 +102,11 @@ Default:
101102
cookieRedirect: false,
102103
}
103104
```
104-
- `login`: User will be redirected to this path if not authenticated or after logout.
105+
106+
- `login`: User will be redirected to this path if not authenticated or after logout.
105107
- `callback`: This is the path the user will be redirect to after supabase login redirection. Should match configured `redirectTo` option of your [signIn method](https://supabase.com/docs/reference/javascript/auth-signinwithoauth). Should also be configured in your Supabase dashboard under `Authentication -> URL Configuration -> Redirect URLs`.
106108
- `exclude`: Routes to exclude from the redirect. `['/foo', '/bar/*']` will exclude the `foo` page and all pages in your `bar` folder.
107-
- `cookieRedirect`: Sets a cookie containing the path an unauthenticated user tried to access. The cookie can then be used on the [`/confirm`](https://supabase.nuxtjs.org/authentication#confirm-page-confirm) page to redirect the user to the page they previously tried to visit.
109+
- `cookieRedirect`: Sets a cookie containing the path an unauthenticated user tried to access. The cookie can then be used on the [`/confirm`](https://supabase.nuxtjs.org/authentication#confirm-page-confirm) page to redirect the user to the page they previously tried to visit.
108110
109111
### `cookieName`
110112
@@ -121,11 +123,13 @@ Cookie name used for storing access and refresh tokens, added in front of `-acce
121123
secure: true
122124
}
123125
```
126+
124127
Options for cookies used to share tokens between server and client, refer to [cookieOptions](https://nuxt.com/docs/api/composables/use-cookie#options) for available settings. Please note that the lifetime set here does not determine the Supabase session lifetime.
125128
126129
### `clientOptions`
127130
128131
Default:
132+
129133
```ts
130134
clientOptions: {
131135
auth: {
@@ -135,14 +139,16 @@ Default:
135139
autoRefreshToken: true
136140
},
137141
}
138-
```
142+
```
139143
140144
Supabase client options [available here](https://supabase.com/docs/reference/javascript/initializing#parameters).
141145
142146
## Versions
143147
144148
`0.1.x` versions are wrapped around `supabase-js v1`.
145-
<br>
149+
150+
:br
151+
146152
`1.x.x` versions are wrapped around `supabase-js v2`.
147153
148154
## Demo

docs/content/3.authentication.md

+33-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Authentication
33
icon: heroicons:lock-closed
4-
description: 'Authenticate your user thanks to the PKCE Oauth protocol that enables secure exchange of refresh and access tokens between an application and the authorization server'
4+
description: Authenticate your user thanks to the PKCE Oauth protocol that enables secure exchange of refresh and access tokens between an application and the authorization server
55
---
66

77
With the default options, the module requires a log-in page and a confirm page to handle the [PKCE authorization code flow](https://supabase.com/docs/guides/resources/glossary#pkce). If you want to understand how it works under the hood, you can read this [section](https://supabase.com/docs/guides/auth/server-side-rendering#understanding-the-authentication-flow).
@@ -14,8 +14,7 @@ For advanced users who want to implement the auth behaviour themselves, you can
1414

1515
## Log-in page - `/login`
1616

17-
Each time a user is trying to access a page that needs authentication, he will automatically be redirected to the configured log in page. If you want to allow access to "public" page, you just need to add them in the [exclude](/get-started#redirectoptions) redirect option.
18-
17+
Each time a user is trying to access a page that needs authentication, he will automatically be redirected to the configured log in page. If you want to allow access to "public" page, you just need to add them in the [exclude](/get-started#redirectoptions) redirect option.
1918

2019
::callout{icon="i-heroicons-exclamation-triangle-20-solid" color="amber"}
2120
Ensure to activate the authentication providers you want in the Supabase Dashboard under `Authentication -> Providers`.
@@ -61,24 +60,47 @@ The confirmation page receives the supabase callback. From there you can check t
6160
The redirect URL must be configured in your Supabase dashboard under `Authentication -> URL Configuration -> Redirect URLs`.
6261
::
6362

64-
6563
```vue [pages/confirm.vue]
6664
<script setup lang="ts">
6765
const user = useSupabaseUser()
6866
69-
// Pull in the config to get cookie details
70-
const config = useRuntimeConfig().public.supabase;
71-
const { cookieName } = config;
72-
const redirectPath = useCookie(`${cookieName}-redirect-path`).value;
67+
watch(user, () => {
68+
if (user.value) {
69+
// Redirect to protected page
70+
return navigateTo('/')
71+
}
72+
}, { immediate: true })
73+
</script>
74+
75+
<template>
76+
<div>Waiting for login...</div>
77+
</template>
78+
```
79+
80+
### Redirect path
81+
82+
You can easily handle redirection to the initial requested route after login.
7383

84+
::callout{icon="i-heroicons-light-bulb"}
85+
You must enable the `cookieRedirect` option of the [redirectOptions](/get-started#redirectoptions) to allow cookie storage and take benefit of this feature.
86+
::
87+
88+
```vue [pages/confirm.vue]
89+
<script setup lang="ts">
90+
const user = useSupabaseUser()
91+
92+
// Get redirect path from cookies
93+
const config = useRuntimeConfig().public.supabase.cookieName
94+
const redirectPath = useCookie(`${cookieName}-redirect-path`).value
7495
7596
watch(user, () => {
7697
if (user.value) {
77-
useCookie(`${cookieName}-redirect-path`).value = null // Clear the cookie
78-
return navigateTo(redirectPath || '/'); // Redirect or go to protected page
98+
// Clear cookie
99+
useCookie(`${cookieName}-redirect-path`).value = null
100+
// Redirect to path
101+
return navigateTo(redirectPath || '/');
79102
}
80103
}, { immediate: true })
81-
82104
</script>
83105
<template>
84106
<div>Waiting for login...</div>

docs/content/4.usage/composables/useSupabaseClient.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const { data: restaurant } = await useAsyncData('restaurant', async () => {
6060

6161
## Realtime
6262

63-
Based on [Supabase Realtime](https://github.com/supabase/realtime), listen to changes in your PostgreSQL Database and broadcasts them over WebSockets.
63+
Based on [Supabase Realtime](https://github.com/supabase/realtime), listen to changes in your PostgreSQL Database and broadcasts them over WebSockets.
6464

6565
To enable it, make sure you have turned on the [Realtime API](https://supabase.com/docs/guides/api#realtime-api) for your table.
6666

@@ -109,4 +109,3 @@ import type { Database } from '~/types'
109109
const client = useSupabaseClient<Database>()
110110
</script>
111111
```
112-

docs/content/4.usage/services/1.serverSupabaseClient.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ title: serverSupabaseClient
33
description: Make requests to the Supabase API on server side with the serverSupabaseClient service
44
---
55

6-
7-
::callout{icon="i-heroicons-exclamation-triangle-20-solid" color="amber"}
8-
This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.
6+
::callout{color="amber" icon="i-heroicons-exclamation-triangle-20-solid"}
7+
This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.
98
::
109

1110
This function is working similary as the [useSupabaseClient](/usage/composables/usesupabaseclient) composable but is designed to be used in [server routes](https://nuxt.com/docs/guide/directory-structure/server#server-routes).

docs/content/4.usage/services/2.serverSupabaseServiceRole.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
22
title: serverServiceRole
33
description: Make requests with super admin rights to the Supabase API with the serverSupabaseServiceRole service
4-
navigation.title: serverSupabaseServiceRole
4+
navigation:
5+
title: serverSupabaseServiceRole
56
---
67

7-
::callout{icon="i-heroicons-exclamation-triangle-20-solid" color="amber"}
8-
This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.
8+
::callout{color="amber" icon="i-heroicons-exclamation-triangle-20-solid"}
9+
This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.
910
::
1011

11-
This function is designed to work only in [server routes](https://nuxt.com/docs/guide/directory-structure/server#server-routes), there is no vue composable equivalent.
12+
This function is designed to work only in [server routes](https://nuxt.com/docs/guide/directory-structure/server#server-routes), there is no vue composable equivalent.
1213

1314
It works similary as the [serverSupabaseClient](/usage/services/serversupabaseclient) but it provides a client with super admin rights that can bypass your [Row Level Security](https://supabase.com/docs/guides/auth/row-level-security).
1415

docs/content/4.usage/services/3.serverSupabaseUser.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: serverSupabaseUser
33
description: Get your Supabase user from serverside with the serverSupabaseUser service
44
---
55

6-
::callout{icon="i-heroicons-exclamation-triangle-20-solid" color="amber"}
7-
This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.
6+
::callout{color="amber" icon="i-heroicons-exclamation-triangle-20-solid"}
7+
This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.
88
::
99

1010
This function is similar to the [useSupabaseUser](/usage/composables/usesupabaseuser) composable but is used in [server routes](https://nuxt.com/docs/guide/directory-structure/server#server-routes).

docs/content/5.demo.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Follow the instruction in the [demo Readme](https://github.com/nuxt-community/su
1818

1919
## Source code
2020

21-
The source code is available on Github in the [demo/ directory](https://github.com/nuxt-community/supabase-module/tree/main/demo).
21+
The source code is available on Github in the [demo/ directory](https://github.com/nuxt-community/supabase-module/tree/main/demo).

docs/content/6.changelog.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ description: Discover the latest updates of the Supabase Module
66

77
Discover the lastest updates.
88

9-
:releases
9+
::releases
10+
::

docs/content/7.roadmap.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ description: Discover our kaban board for the next release of the Supabase modul
44
icon: heroicons:map
55
---
66

7-
:volta-board{token="eyJzdGF0dXNlcyI6WyJ0cmlhZ2UiLCJiYWNrbG9nIiwidG9kbyIsImluX3Byb2dyZXNzIiwiaW5fcmV2aWV3IiwiZG9uZSIsInJlbGVhc2VkIiwiY2FuY2VsbGVkIl0sImZpbHRlcnMiOnt9LCJvd25lciI6Im51eHQtbW9kdWxlcyIsIm5hbWUiOiJzdXBhYmFzZSJ9"}
7+
::volta-board
8+
---
9+
token: eyJzdGF0dXNlcyI6WyJ0cmlhZ2UiLCJiYWNrbG9nIiwidG9kbyIsImluX3Byb2dyZXNzIiwiaW5fcmV2aWV3IiwiZG9uZSIsInJlbGVhc2VkIiwiY2FuY2VsbGVkIl0sImZpbHRlcnMiOnt9LCJvd25lciI6Im51eHQtbW9kdWxlcyIsIm5hbWUiOiJzdXBhYmFzZSJ9
10+
---
11+
::

0 commit comments

Comments
 (0)