mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Fix prettier
This commit is contained in:
1 parent
e260f6a2d2
commit
ecdc3465fd
3 files changed
+68
-26
No files matched your search
@@ -82,9 +82,7 @@ Previously `nullsFirst` defaults to `false` , meaning `null`s are ordered last.
|
||||
Storage key name in the Auth library has changed to include project reference which means that existing websites that had their JWT expiry set to a longer time could find their users logged out with this upgrade.
|
||||
|
||||
```jsx
|
||||
const defaultStorageKey = `sb-${
|
||||
new URL(this.authUrl).hostname.split('.')[0]
|
||||
}-auth-token`
|
||||
const defaultStorageKey = `sb-${new URL(this.authUrl).hostname.split('.')[0]}-auth-token`
|
||||
```
|
||||
|
||||
### New Auth Types
|
||||
|
||||
@@ -13,12 +13,11 @@ No new features will be added to supabase-js v1 , but we'll continuing merging s
|
||||
|
||||
## Upgrade the client library
|
||||
|
||||
|
||||
```sh
|
||||
npm install @supabase/supabase-js@2
|
||||
```
|
||||
|
||||
*Optionally* if you are using custom configuration with `createClient` then follow below:
|
||||
_Optionally_ if you are using custom configuration with `createClient` then follow below:
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
@@ -32,9 +31,10 @@ npm install @supabase/supabase-js@2
|
||||
```ts title="src/supabaseClient.ts"
|
||||
const supabaseClient = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
||||
schema: 'custom',
|
||||
persistSession: false
|
||||
persistSession: false,
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -42,13 +42,14 @@ const supabaseClient = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
||||
```ts title="src/supabaseClient.ts"
|
||||
const supabaseClient = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
||||
db: {
|
||||
schema: 'custom'
|
||||
schema: 'custom',
|
||||
},
|
||||
auth: {
|
||||
persistSession: true
|
||||
}
|
||||
persistSession: true,
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -59,6 +60,7 @@ Read more about the [constructor options](/docs/reference/javascript/release-not
|
||||
The signIn() method has been deprecated in favor of more explicit method signatures to help with type hinting. Previously it was difficult for developers to know what they were missing (e.g., a lot of developers didn't realize they could use passwordless magic links).
|
||||
|
||||
#### Sign in with email and password
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -71,17 +73,23 @@ The signIn() method has been deprecated in favor of more explicit method signatu
|
||||
```ts
|
||||
const { user, error } = await supabase.auth.signIn({ email, password })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
|
||||
```ts
|
||||
const { data: { user }, error } = await supabase.auth.signInWithPassword({ email, password })
|
||||
const {
|
||||
data: { user },
|
||||
error,
|
||||
} = await supabase.auth.signInWithPassword({ email, password })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Sign in with magic link
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -94,6 +102,7 @@ const { data: { user }, error } = await supabase.auth.signInWithPassword({ email
|
||||
```ts
|
||||
const { error } = await supabase.auth.signIn({ email })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -101,10 +110,12 @@ const { error } = await supabase.auth.signIn({ email })
|
||||
```ts
|
||||
const { error } = await supabase.auth.signInWithOtp({ email })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Sign in with a third-party provider
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -117,6 +128,7 @@ const { error } = await supabase.auth.signInWithOtp({ email })
|
||||
```ts
|
||||
const { error } = await supabase.auth.signIn({ provider })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -124,10 +136,12 @@ const { error } = await supabase.auth.signIn({ provider })
|
||||
```ts
|
||||
const { error } = await supabase.auth.signInWithOAuth({ provider })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Sign in with phone
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -140,6 +154,7 @@ const { error } = await supabase.auth.signInWithOAuth({ provider })
|
||||
```ts
|
||||
const { error } = await supabase.auth.signIn({ phone, password })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -147,10 +162,12 @@ const { error } = await supabase.auth.signIn({ phone, password })
|
||||
```ts
|
||||
const { error } = await supabase.auth.signInWithPassword({ phone, password })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Sign in with phone using OTP
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -163,6 +180,7 @@ const { error } = await supabase.auth.signInWithPassword({ phone, password })
|
||||
```ts
|
||||
const { error } = await supabase.auth.api.sendMobileOTP(phone)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -173,10 +191,12 @@ const { data, error } = await supabase.auth.signInWithOtp({ phone })
|
||||
// After receiving a SMS with a OTP.
|
||||
const { data, error } = await supabase.auth.verifyOtp({ phone, token })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Reset password for email
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -189,6 +209,7 @@ const { data, error } = await supabase.auth.verifyOtp({ phone, token })
|
||||
```ts
|
||||
const { data, error } = await supabase.auth.api.resetPasswordForEmail(email)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -196,10 +217,12 @@ const { data, error } = await supabase.auth.api.resetPasswordForEmail(email)
|
||||
```ts
|
||||
const { data, error } = await supabase.auth.resetPasswordForEmail(email)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Get the user's current session
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -212,17 +235,22 @@ const { data, error } = await supabase.auth.resetPasswordForEmail(email)
|
||||
```ts
|
||||
const session = supabase.auth.session()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
|
||||
```ts
|
||||
const { data: { session } } = await supabase.auth.getSession()
|
||||
const {
|
||||
data: { session },
|
||||
} = await supabase.auth.getSession()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Get the logged-in user
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -235,18 +263,23 @@ const { data: { session } } = await supabase.auth.getSession()
|
||||
```ts
|
||||
const user = supabase.auth.user()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
|
||||
```ts
|
||||
const { data: { session } } = await supabase.auth.getSession()
|
||||
const {
|
||||
data: { session },
|
||||
} = await supabase.auth.getSession()
|
||||
const { user } = session
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Update user data for a logged-in user
|
||||
|
||||
<Tabs
|
||||
groupId="version"
|
||||
values={[
|
||||
@@ -259,13 +292,18 @@ const { user } = session
|
||||
```ts
|
||||
const { user, error } = await supabase.auth.update({ attributes })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
|
||||
```ts
|
||||
const { data: { user }, error } = await supabase.auth.updateUser({ attributes })
|
||||
const {
|
||||
data: { user },
|
||||
error,
|
||||
} = await supabase.auth.updateUser({ attributes })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -283,19 +321,21 @@ const { data: { user }, error } = await supabase.auth.updateUser({ attributes })
|
||||
```ts
|
||||
const { user, error } = supabase.auth.setAuth(access_token)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
|
||||
```ts
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
||||
global: {
|
||||
global: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${access_token}`
|
||||
}
|
||||
}
|
||||
Authorization: `Bearer ${access_token}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -319,6 +359,7 @@ Previously, these methods return inserted/updated/deleted rows by default (which
|
||||
```ts
|
||||
const { data, error } = await supabase.auth.insert({ new_data })
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -326,6 +367,7 @@ const { data, error } = await supabase.auth.insert({ new_data })
|
||||
```ts
|
||||
const { data, error } = await supabase.auth.insert({ new_data }).select()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -343,6 +385,7 @@ const { data, error } = await supabase.auth.insert({ new_data }).select()
|
||||
```ts
|
||||
const { data, error } = await supabase.auth.update({ new_data }).eq('id', id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -350,6 +393,7 @@ const { data, error } = await supabase.auth.update({ new_data }).eq('id', id)
|
||||
```ts
|
||||
const { data, error } = await supabase.auth.update({ new_data }).eq('id', id).select()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -367,12 +411,12 @@ const { data, error } = await supabase.auth.update({ new_data }).eq('id', id).se
|
||||
<TabItem value="1.x">
|
||||
|
||||
```ts
|
||||
const userListener = supabase.from('users')
|
||||
.on('*',
|
||||
(payload) => handleAllEventsPayload(payload.new)
|
||||
)
|
||||
const userListener = supabase
|
||||
.from('users')
|
||||
.on('*', (payload) => handleAllEventsPayload(payload.new))
|
||||
.subscribe()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -386,6 +430,7 @@ const userListener = supabase.channel('public:user')
|
||||
)
|
||||
.subscribe()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -403,6 +448,7 @@ const userListener = supabase.channel('public:user')
|
||||
```ts
|
||||
userListener.unsubscribe()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="2.x">
|
||||
@@ -410,5 +456,6 @@ userListener.unsubscribe()
|
||||
```ts
|
||||
supabase.removeChannel('public:users')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
</Tabs>
|
||||
@@ -43,10 +43,7 @@ You can enrich the supabase client with the types you generated with Supabase.
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import { Database } from 'lib/database.types'
|
||||
|
||||
const supabase = createClient<Database>(
|
||||
process.env.SUPABASE_URL,
|
||||
process.env.SUPABASE_ANON_KEY
|
||||
)
|
||||
const supabase = createClient<Database>(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY)
|
||||
```
|
||||
|
||||
## Type hints
|
||||
|
||||
Reference in new issue
Block a user