Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

update refreshSession & setSession examples

Kang Mingb073bd802aaf
diff --git a/spec/common-client-libs-sections.json b/spec/common-client-libs-sections.json
index bbe1a567df5..80d8eb32b82 100644
--- a/spec/common-client-libs-sections.json
+++ b/spec/common-client-libs-sections.json
@@ -555,7 +555,6 @@
"type": "function",
"libs": ["js"]
},
-
{
"id": "on-auth-state-change",
"title": "Listen to auth events",
diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.yml
index 8a570bca50f..fe90746ae25 100644
--- a/spec/supabase_js_v2.yml
+++ b/spec/supabase_js_v2.yml
@@ -396,28 +396,32 @@ functions:
isSpotlight: true
code: |
```js
- const { data, error } = supabase.auth.setSession(refresh_token)
+ const { data, error } = supabase.auth.setSession({
+ access_token,
+ refresh_token
+ )
```
- id: refresh-session
title: 'refreshSession()'
$ref: '@supabase/gotrue-js.GoTrueClient.refreshSession'
notes: |
- This method will refresh the session whether the current one is expired or not.
- - Both examples destructure `user` and `session` from `data`. This is not required; so `const { data, error } =` is also valid.
examples:
- id: refresh-session-using-the-current-session
name: Refresh session using the current session
isSpotlight: true
code: |
```js
- const { data: { user, session }, error } = await supabase.auth.refreshSession()
+ const { data, error } = await supabase.auth.refreshSession()
+ const { session, user } = data
```
- id: refresh-session-using-a-passed-in-session
- name: Refresh session using a passed-in session
- isSpotlight: true
+ name: Refresh session using a refresh token
+ isSpotlight: false
code: |
```js
- const { data: { user, session }, error } = await supabase.auth.refreshSession({ refresh_token })
+ const { data, error } = await supabase.auth.refreshSession({ refresh_token })
+ const { session, user } = data
```
- id: on-auth-state-change
title: 'onAuthStateChange()'