Skip to content

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

Add Kotlin docs to Auth, Realtime and Storage (#17700)

Jan Tennert82a6e009514a
diff --git a/apps/docs/pages/guides/auth/auth-email.mdx b/apps/docs/pages/guides/auth/auth-email.mdx
index 827b27aa19f..94f6d7548c2 100644
--- a/apps/docs/pages/guides/auth/auth-email.mdx
+++ b/apps/docs/pages/guides/auth/auth-email.mdx
@@ -61,6 +61,20 @@ Future<void> signInWithEmail() async {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Email)](/docs/reference/kotlin/auth-signinwithpassword) with their email address and password:
+
+```kotlin
+suspend fun signInWithEmail() {
+ supabase.gotrue.loginWith(Email) {
+ email = "[email protected]"
+ password = "example-password"
+ }
+}
+```
+
</TabPanel>
</Tabs>
@@ -92,6 +106,17 @@ Future<void> signOut() async {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun logout() {
+ supabase.gotrue.logout()
+}
+```
+
</TabPanel>
</Tabs>
diff --git a/apps/docs/pages/guides/auth/auth-magic-link.mdx b/apps/docs/pages/guides/auth/auth-magic-link.mdx
index 3367d833365..37e8e8ead2a 100644
--- a/apps/docs/pages/guides/auth/auth-magic-link.mdx
+++ b/apps/docs/pages/guides/auth/auth-magic-link.mdx
@@ -60,6 +60,19 @@ Future<void> signInWithEmail() async {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [sendOtpTo()](/docs/reference/kotlin/auth-signinwithotp) with their email address:
+
+```kotlin
+suspend fun loginWithEmail() {
+ supabase.gotrue.sendOtpTo(Email) {
+ email = "[email protected]"
+ }
+}
+```
+
</TabPanel>
</Tabs>
@@ -90,6 +103,17 @@ Future<void> signOut() async {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun logout() {
+ supabase.gotrue.logout()
+}
+```
+
</TabPanel>
</Tabs>
diff --git a/apps/docs/pages/guides/auth/auth-password-reset.mdx b/apps/docs/pages/guides/auth/auth-password-reset.mdx
index 2f76e690ead..5b55a245325 100644
--- a/apps/docs/pages/guides/auth/auth-password-reset.mdx
+++ b/apps/docs/pages/guides/auth/auth-password-reset.mdx
@@ -14,30 +14,92 @@ export const meta = {
## Single Page Application (SPA)
### Sending password reset email
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Supabase provides a convenient method [`.resetPasswordForEmail`](/docs/reference/javascript/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectTo` which we will use to pass an absolute URL to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user.
-```ts
+```js
await supabase.auth.resetPasswordForEmail('[email protected]', {
redirectTo: 'http://example.com/account/update-password',
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Supabase provides a convenient method [`.sendRecoveryEmail`](/docs/reference/kotlin/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectUrl` which we will use to pass an absolute URL to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user.
+
+```kotlin
+supabase.gotrue.sendRecoveryEmail(
+ email = "[email protected]",
+ redirectUrl = "http://example.com/account/update-password"
+)
+```
+
+If you are on one of the Kotlin targets that have built-in support for redirect url handling like Android, you may want to checkout [OAuth and OTP link verification](https://supabase.com/docs/reference/kotlin/initializing).
+
+</TabPanel>
+</Tabs>
+
### Email link
+
The email link you receive will work like a magic link. This way when you click the link you will be logged into the website. Since we passed a redirect URL to the [`.resetPasswordForEmail`](https://supabase.com/docs/reference/javascript/auth-resetpasswordforemail) method the user should be sent to the update password page.
### Update Password
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
To update the password we call the [`.updateUser`](/docs/reference/javascript/auth-updateuser) method and pass along the new password to this method.
-```ts
+```js
await supabase.auth.updateUser({ password: new_password })
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+To update the password we call the [`.modifyUser`](/docs/reference/kotlin/auth-updateuser) method and pass along the new password to this method.
+
+```kotlin
+supabase.gotrue.modifyUser {
+ password = "new_password"
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Server-Side Rendering (SSR)
### Sending password reset email
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Supabase provides a convenient method [`.resetPasswordForEmail`](/docs/reference/javascript/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectTo` which we will use to pass an absolute URL to the callback page along with a query parameter to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user.
-```ts
+```js
await supabase.auth.resetPasswordForEmail('[email protected]', {
redirectTo: 'http://example.com/api/auth/callback?next=/account/update-password',
})
@@ -49,13 +111,41 @@ We are using `next` as our query parameter, but this can name whatever you like.
</Admonition>
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Supabase provides a convenient method [`.sendRecoveryEmail`](/docs/reference/kotlin/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectUrl` which we will use to pass an absolute URL to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user.
+
+```kotlin
+supabase.gotrue.sendRecoveryEmail(
+ email = "[email protected]",
+ redirectUrl = "http://example.com/api/auth/callback?next=/account/update-password"
+)
+```
+
+If you are on one of the Kotlin targets that have built-in support for redirect url handling like Android, you may want to checkout [OAuth and OTP link verification](https://supabase.com/docs/reference/kotlin/initializing).
+
+</TabPanel>
+</Tabs>
+
### Email link
+
The email link you receive will behave like a magic link. When the link is clicked you will be sent to the `redirectTo` URL you specified that points to the path with the exchange code.
### Exchange authorization code
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
After redirecting to the server page, we need to retrieve the code from the query parameter called `code` and pass it to the `.exchangeCodeForSession` function.
-```ts
+```js
// api/auth/callback.ts
// The code is retrieved from the query parameter - use whichever mechanism is recommended
@@ -85,14 +175,76 @@ const next = url.searchParams.get('next')
res.redirect(next)
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Here is an example on Android:
+
+```kotlin
+//Wherever you initialize your SupabaseClient:
+val client = createSupabaseClient(supabaseUrl, supabaseKey) {
+ install(GoTrue) {
+ flowType = FlowType.PKCE
+ scheme = "exampleApp"
+ host = "callback"
+ }
+}
+```
+
+```xml
+<!-- AndroidManifest.xml -->
+<intent-filter>
+ <category android:name="android.intent.category.DEFAULT" />
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="exampleApp" android:host="callback" />
+</intent-filter>
+```
+
+```kotlin
+//MainActivity.kt
+override fun onCreate() {
+ client.handleDeeplinks(intent)
+}
+```
+
+That's it! `supabase-kt` will take care of parsing and importing the session. Other targets are similar, you can check [OAuth and OTP link verification](https://supabase.com/docs/reference/kotlin/initializing) for more information.
+
+</TabPanel>
+</Tabs>
+
### Update Password
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
To update the password we call the [`.updateUser`](/docs/reference/javascript/auth-updateuser) method and pass along the new password to this method.
-```ts
+```js
await supabase.auth.updateUser({ password: new_password })
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+To update the password we call the [`.modifyUser`](/docs/reference/kotlin/auth-updateuser) method and pass along the new password to this method.
+
+```kotlin
+supabase.gotrue.modifyUser {
+ password = "new_password"
+}
+```
+
+</TabPanel>
+</Tabs>
+
export const Page = ({ children }) => <Layout meta={meta} children={children} />
export default Page
-
diff --git a/apps/docs/pages/guides/auth/managing-user-data.mdx b/apps/docs/pages/guides/auth/managing-user-data.mdx
index 1c6bc8e212a..4412465450b 100644
--- a/apps/docs/pages/guides/auth/managing-user-data.mdx
+++ b/apps/docs/pages/guides/auth/managing-user-data.mdx
@@ -42,11 +42,13 @@ You may delete users directly or via the management console at Authentication >
You cannot delete a user if they are the owner of any objects in Supabase Storage.
You will encounter an error when you try to delete an Auth user that owns any Storage objects. If this happens, try deleting all the objects for that user, or reassign ownership to another user.
+
</Admonition>
## Exporting Users
As Supabase is built on top of PostgreSQL, you can query the `auth.users` and `auth.identities` table via the `SQL Editor` tab to extract all users:
+
```sql
select * from auth.users;
```
@@ -54,7 +56,6 @@ select * from auth.users;
You can also opt to export the results via CSV through the dashboard if you wish:
![export_users.png](/docs/img/guides/auth-managing-user-data/export_users.png)
-
## Public access
Since Row Level Security is enabled, this table is accessible via the API but no data will be returned unless we set up some Policies.
@@ -86,6 +87,15 @@ create policy "Profiles are viewable by users who created them."
The nice thing about this pattern? We can now query this table via the API and we don't need to include data filters in our API queries - the Policies will handle that for us:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
// This will return nothing while the user is logged out
const { data } = await supabase.from('profiles').select('id, username, avatar_url, website')
@@ -98,6 +108,24 @@ const { data: profile } = await supabase
.select('id, username, avatar_url, website')
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+// This will return nothing while the user is logged out
+val data = supabase.postgrest["profiles"].select(Columns.list("id", "username", "avatar_url", "website"))
+
+// After the user is logged in, this will only return
+// the logged-in user's data - in this case a single row
+supabase.gotrue.sendOtpTo(Email) {
+ this.email = email
+}
+val data = supabase.postgrest["profiles"].select(Columns.list("id", "username", "avatar_url", "website"))
+```
+
+</TabPanel>
+</Tabs>
+
## Bypassing Row Level Security
If you need to fetch a full list of user profiles, we supply a `service_key` which you can use with your API and Client Libraries to bypass Row Level Security.
@@ -108,6 +136,15 @@ Make sure you _NEVER_ expose this publicly. But it can be used on the server-sid
You can assign metadata to users on sign up:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const { data, error } = await supabase.auth.signUp({
@@ -121,8 +158,34 @@ const { data, error } = await supabase.auth.signUp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val data = supabase.gotrue.signUpWith(Email) {
+ email = "[email protected]"
+ password = "example-password"
+ data = buildJsonObject {
+ put("first_name", "John")
+ put("age", 27)
+ }
+}
+```
+
+</TabPanel>
+</Tabs>
+
User metadata is stored on the `raw_user_meta_data` column of the `auth.users` table. To view the metadata:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const {
data: { user },
@@ -130,6 +193,19 @@ const {
let metadata = user.user_metadata
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val user = supabase.gotrue.retrieveUserForCurrentSession()
+//Or you can use the user from the current session:
+val user = supabase.gotrue.currentUserOrNull()
+val metadata = user?.userMetadata
+```
+
+</TabPanel>
+</Tabs>
+
## Advanced techniques
### Using triggers
diff --git a/apps/docs/pages/guides/auth/phone-login/messagebird.mdx b/apps/docs/pages/guides/auth/phone-login/messagebird.mdx
index c0de63b0366..659b108e57f 100644
--- a/apps/docs/pages/guides/auth/phone-login/messagebird.mdx
+++ b/apps/docs/pages/guides/auth/phone-login/messagebird.mdx
@@ -76,8 +76,6 @@ Use the variable `.Code` in the template to display the code.
In this use scenario we'll be using the user's mobile phone number as an alternative to an email address when signing up along with a password. You may want to think hard about the permanency of this however. It is not uncommon for mobile phone numbers to be recycled by phone networks when users cancel their phone contracts or move countries, therefore granting access to the user's account to whoever takes over the phone number in the future. Soon we'll add multi-factor auth, which will mitigate this risk, but for now you may want to give some thought to allowing your users to recover their account by some other means in an emergency.
-Using supabase-js on the client you'll want to use the same `signUp` method that you'd use for email based sign ups, but with the `phone` param instead of the `email param`:
-
<Tabs
scrollable
size="small"
@@ -87,6 +85,8 @@ Using supabase-js on the client you'll want to use the same `signUp` method that
>
<TabPanel id="js" label="JavaScript">
+Using supabase-js on the client you'll want to use the same `signUp` method that you'd use for email based sign ups, but with the `phone` param instead of the `email param`:
+
```js
let { user, error } = await supabase.auth.signUp({
phone: '+13334445555',
@@ -94,6 +94,16 @@ let { user, error } = await supabase.auth.signUp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.signUpWith(Phone) {
+ phoneNumber = "+13334445555"
+ password = "some-password"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -112,8 +122,6 @@ curl -X POST 'https://cvwawazfelidkloqmbma.supabase.co/auth/v1/signup' \
The user will now receive an SMS with a 6-digit pin that you will need to receive from them within 60-seconds before they can login to their account.
-You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:
-
<Tabs
scrollable
size="small"
@@ -123,6 +131,8 @@ You should present a form to the user so they can input the 6 digit pin, then se
>
<TabPanel id="js" label="JavaScript">
+You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:
+
```js
let { session, error } = await supabase.auth.verifyOtp({
phone: '+13334445555',
@@ -130,6 +140,19 @@ let { session, error } = await supabase.auth.verifyOtp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyPhoneOtp`:
+
+```kotlin
+supabase.gotrue.verifyPhoneOtp(
+ type = OtpType.Phone.SMS,
+ phoneNumber = "+13334445555",
+ token = "123456"
+)
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -178,6 +201,16 @@ let { user, error } = await supabase.auth.signInWithPassword({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.loginWith(Phone) {
+ phoneNumber = "+13334445555"
+ password = "some-password"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -198,8 +231,6 @@ curl -X POST 'https://cvwawazfelidkloqmbma.supabase.co/auth/v1/token?grant_type=
In this scenario you are granting your user's the ability to login to their account without needing to set a password on their account, all they have to do to log in is verify their mobile each time using the OTP.
-In javascript we can use the `signIn` method with a single parameter: `phone`
-
<Tabs
scrollable
size="small"
@@ -209,12 +240,25 @@ In javascript we can use the `signIn` method with a single parameter: `phone`
>
<TabPanel id="js" label="JavaScript">
+In JavaScript we can use the `signIn` method with a single parameter: `phone`
+
```js
let { user, error } = await supabase.auth.signInWithOtp({
phone: '+13334445555',
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+In Kotlin, we can use the `sendOtpTo` method and change the property `phoneNumber`
+
+```kotlin
+supabase.gotrue.sendOtpTo(Phone) {
+ phoneNumber = "+13334445555"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -248,6 +292,17 @@ let { session, error } = await supabase.auth.verifyOtp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.verifyPhoneOtp(
+ type = OtpType.Phone.SMS,
+ phoneNumber = "+13334445555",
+ token = "123456"
+)
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
diff --git a/apps/docs/pages/guides/auth/phone-login/twilio.mdx b/apps/docs/pages/guides/auth/phone-login/twilio.mdx
index ebf8da95918..4f9f7e721f2 100644
--- a/apps/docs/pages/guides/auth/phone-login/twilio.mdx
+++ b/apps/docs/pages/guides/auth/phone-login/twilio.mdx
@@ -122,8 +122,6 @@ Use the variable `.Code` in the template to display the OTP code. Here's an exam
In this scenario we'll be using the user's mobile phone number and a corresponding password as an alternative to signing up with an email address. Note: please thoroughly consider potential security implications when signing up with a combination of phone number and password. Phone numbers are sometimes recycled by phone networks when users cancel their phone contracts or move countries, thereby granting access to the user's account to the subsequent owner of the phone number. In the near future Supabase will support multifactor authentication, which will mitigate this risk, but for now you may want to consider allowing your users to recover their account by some other means in an emergency.
-Using supabase-js on the client you'll want to use the same `signUp` method that you'd use for email based sign ups, but with the `phone` param instead of the `email param`:
-
<Tabs
scrollable
size="small"
@@ -133,6 +131,8 @@ Using supabase-js on the client you'll want to use the same `signUp` method that
>
<TabPanel id="js" label="JavaScript">
+Using supabase-js on the client you'll want to use the same `signUp` method that you'd use for email based sign ups, but with the `phone` param instead of the `email param`:
+
```js
let { user, error } = await supabase.auth.signUp({
phone: '+13334445555',
@@ -140,6 +140,16 @@ let { user, error } = await supabase.auth.signUp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.signUpWith(Phone) {
+ phoneNumber = "+13334445555"
+ password = "some-password"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -158,8 +168,6 @@ curl -X POST 'https://cvwawazfelidkloqmbma.supabase.co/auth/v1/signup' \
The user will now receive an SMS with a 6-digit pin that you will need to receive from them within 60-seconds before they can login to their account.
-You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:
-
<Tabs
scrollable
size="small"
@@ -169,6 +177,8 @@ You should present a form to the user so they can input the 6 digit pin, then se
>
<TabPanel id="js" label="JavaScript">
+You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:
+
```js
let { session, error } = await supabase.auth.verifyOtp({
phone: '+13334445555',
@@ -177,6 +187,19 @@ let { session, error } = await supabase.auth.verifyOtp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyPhoneOtp`:
+
+```kotlin
+supabase.gotrue.verifyPhoneOtp(
+ type = OtpType.Phone.SMS,
+ phoneNumber = "+13334445555",
+ token = "123456"
+)
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -225,6 +248,16 @@ let { user, error } = await supabase.auth.signInWithPassword({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.loginWith(Phone) {
+ phoneNumber = "+13334445555"
+ password = "some-password"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -245,8 +278,6 @@ curl -X POST 'https://cvwawazfelidkloqmbma.supabase.co/auth/v1/token?grant_type=
In this scenario you are granting your user's the ability to login to their account without needing to set a password on their account, all they have to do to log in is verify their mobile each time using the OTP.
-In javascript we can use the `signIn` method with a single parameter: `phone`
-
<Tabs
scrollable
size="small"
@@ -256,12 +287,25 @@ In javascript we can use the `signIn` method with a single parameter: `phone`
>
<TabPanel id="js" label="JavaScript">
+In JavaScript we can use the `signIn` method with a single parameter: `phone`
+
```js
let { user, error } = await supabase.auth.signInWithOtp({
phone: '+13334445555',
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+In Kotlin, we can use the `sendOtpTo` method and change the property `phoneNumber`
+
+```kotlin
+supabase.gotrue.sendOtpTo(Phone) {
+ phoneNumber = "+13334445555"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -296,6 +340,17 @@ let { session, error } = await supabase.auth.verifyOtp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.verifyPhoneOtp(
+ type = OtpType.Phone.SMS,
+ phoneNumber = "+13334445555",
+ token = "123456"
+)
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
diff --git a/apps/docs/pages/guides/auth/phone-login/vonage.mdx b/apps/docs/pages/guides/auth/phone-login/vonage.mdx
index f51d1c2c0e1..f04563c97de 100644
--- a/apps/docs/pages/guides/auth/phone-login/vonage.mdx
+++ b/apps/docs/pages/guides/auth/phone-login/vonage.mdx
@@ -69,8 +69,6 @@ Use the variable `.Code` in the template to display the code.
In this use scenario we'll be using the user's mobile phone number as an alternative to an email address when signing up along with a password. You may want to think hard about the permanency of this however. It is not uncommon for mobile phone numbers to be recycled by phone networks when users cancel their phone contracts or move countries, therefore granting access to the user's account to whoever takes over the phone number in the future.
-Using supabase-js on the client you'll want to use the same `signUp` method that you'd use for email based sign ups, but with the `phone` param instead of the `email param`:
-
<Tabs
scrollable
size="small"
@@ -80,6 +78,8 @@ Using supabase-js on the client you'll want to use the same `signUp` method that
>
<TabPanel id="js" label="JavaScript">
+Using supabase-js on the client you'll want to use the same `signUp` method that you'd use for email based sign ups, but with the `phone` param instead of the `email param`:
+
```js
let { user, error } = await supabase.auth.signUp({
phone: '491512223334444',
@@ -87,6 +87,16 @@ let { user, error } = await supabase.auth.signUp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.signUpWith(Phone) {
+ phoneNumber = "+13334445555"
+ password = "some-password"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -105,8 +115,6 @@ curl -X POST 'https://xxx.supabase.co/auth/v1/signup' \
The user will now receive an SMS with a 6-digit pin that you will need to receive from them within 60-seconds before they can login to their account.
-You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:
-
<Tabs
scrollable
size="small"
@@ -116,6 +124,8 @@ You should present a form to the user so they can input the 6 digit pin, then se
>
<TabPanel id="js" label="JavaScript">
+You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:
+
```js
let { session, error } = await supabase.auth.verifyOtp({
phone: '491512223334444',
@@ -123,6 +133,19 @@ let { session, error } = await supabase.auth.verifyOtp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+You should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyPhoneOtp`:
+
+```kotlin
+supabase.gotrue.verifyPhoneOtp(
+ type = OtpType.Phone.SMS,
+ phoneNumber = "+13334445555",
+ token = "123456"
+)
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -171,6 +194,16 @@ let { user, error } = await supabase.auth.signInWithPassword({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.loginWith(Phone) {
+ phoneNumber = "+13334445555"
+ password = "some-password"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -191,8 +224,6 @@ curl -X POST 'https://xxx.supabase.co/auth/v1/token?grant_type=password' \
In this scenario you are granting your user's the ability to login to their account without needing to set a password on their account, all they have to do to log in is verify their mobile each time using the OTP.
-In javascript we can use the `signIn` method with a single parameter: `phone`
-
<Tabs
scrollable
size="small"
@@ -202,12 +233,25 @@ In javascript we can use the `signIn` method with a single parameter: `phone`
>
<TabPanel id="js" label="JavaScript">
+In JavaScript we can use the `signIn` method with a single parameter: `phone`
+
```js
let { user, error } = await supabase.auth.signInWithOtp({
phone: '491512223334444',
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+In Kotlin, we can use the `sendOtpTo` method and change the property `phoneNumber`
+
+```kotlin
+supabase.gotrue.sendOtpTo(Phone) {
+ phoneNumber = "+13334445555"
+}
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
@@ -241,6 +285,17 @@ let { session, error } = await supabase.auth.verifyOtp({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.verifyPhoneOtp(
+ type = OtpType.Phone.SMS,
+ phoneNumber = "+13334445555",
+ token = "123456"
+)
+```
+
</TabPanel>
<TabPanel id="http" label="HTTP">
diff --git a/apps/docs/pages/guides/auth/social-login/auth-apple.mdx b/apps/docs/pages/guides/auth/social-login/auth-apple.mdx
index 43e6f2392ab..dfa327503da 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-apple.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-apple.mdx
@@ -276,6 +276,47 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,
</Admonition>
</TabPanel>
+
+ <TabPanel id="kotlin" label="Kotlin">
+
+ ## Using Native Sign in with Apple in Kotlin
+
+ When using [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform/), you can use the [compose-auth](https://supabase.com/docs/reference/kotlin/installing) plugin. On iOS it uses Native Apple Login automatically and on other platforms it uses `gotrue.loginWith(Apple)`.
+
+ **Initialize the Supabase Client**
+
+ ```kotlin
+ val supabaseClient = createSupabaseClient(
+ supabaseUrl = "SUPABASE_URL",
+ supabaseKey = "SUPABASE_KEY"
+ ) {
+ install(GoTrue)
+ install(ComposeAuth) {
+ nativeAppleLogin()
+ }
+ }
+ ```
+
+ **Use the Compose Auth plugin in your Auth Screen**
+
+ ```kotlin
+ val authState = supabaseClient.composeAuth.rememberLoginWithApple(
+ onResult = {
+ when(it) { //handle errors
+ NativeSignInResult.ClosedByUser -> TODO()
+ is NativeSignInResult.Error -> TODO()
+ is NativeSignInResult.NetworkError -> TODO()
+ NativeSignInResult.Success -> TODO()
+ }
+ }
+ )
+
+ Button(onClick = { authState.startFlow() }) {
+ Text("Sign in with Apple")
+ }
+ ```
+
+ </TabPanel>
</Tabs>
export const Page = ({ children }) => <Layout meta={meta} children={children} />
diff --git a/apps/docs/pages/guides/auth/social-login/auth-azure.mdx b/apps/docs/pages/guides/auth/social-login/auth-azure.mdx
index 637655b64eb..16d41722203 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-azure.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-azure.mdx
@@ -70,6 +70,15 @@ Supabase Auth requires that Azure returns a valid email address. Therefore you m
</Admonition>
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `azure` as the `provider`:
```js
@@ -83,18 +92,66 @@ async function signInWithAzure() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Azure` as the `Provider`:
+
+```kotlin
+suspend fun signInWithAzure() {
+ supabase.gotrue.loginWith(Azure) {
+ scopes.add("email")
+ }
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Obtain the provider refresh token
Azure OAuth2.0 doesn't return the `provider_refresh_token` by default. If you need the `provider_refresh_token` returned, you will need to include the following scope:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
async function signInWithAzure() {
const { data, error } = await supabase.auth.signInWithOAuth({
@@ -106,6 +163,20 @@ async function signInWithAzure() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+suspend fun signInWithAzure() {
+ supabase.gotrue.loginWith(Azure) {
+ scopes.add("offline_access")
+ }
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Azure Developer Account](https://portal.azure.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-bitbucket.mdx b/apps/docs/pages/guides/auth/social-login/auth-bitbucket.mdx
index a1e9abf21d2..7b588b2e611 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-bitbucket.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-bitbucket.mdx
@@ -48,6 +48,15 @@ Setting up Bitbucket logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `bitbucket` as the `provider`:
```js
@@ -58,14 +67,51 @@ async function signInWithBitbucket() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Bitbucket` as the `Provider`:
+
+```kotlin
+suspend fun signInWithBitbucket() {
+ supabase.gotrue.loginWith(Bitbucket)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-discord.mdx b/apps/docs/pages/guides/auth/social-login/auth-discord.mdx
index 3ee781c798f..1f6048fa84e 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-discord.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-discord.mdx
@@ -47,6 +47,15 @@ Setting up Discord logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `discord` as the `provider`:
```js
@@ -57,16 +66,53 @@ async function signInWithDiscord() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Discord` as the `Provider`:
+
+```kotlin
+suspend fun signInWithDiscord() {
+ supabase.gotrue.loginWith(Discord)
+}
+```
+
+</TabPanel>
+</Tabs>
+
If your user is already signed in, Discord prompts the user again for authorization.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-facebook.mdx b/apps/docs/pages/guides/auth/social-login/auth-facebook.mdx
index 36db6d0bbee..2e26c47a947 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-facebook.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-facebook.mdx
@@ -64,6 +64,15 @@ Under `Build Your App`, click on `Use Cases` screen. From there, do the followin
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `facebook` as the `provider`:
```js
@@ -74,14 +83,51 @@ async function signInWithFacebook() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Facebook` as the `Provider`:
+
+```kotlin
+suspend fun signInWithFacebook() {
+ supabase.gotrue.loginWith(Facebook)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
Now, you should be able to login with Facebook and alert you to `Submit for Login Review` when users try to sign into your app. Follow the instructions there to make your app go live for full features and products.
You can read more about App Review [here](https://developers.facebook.com/docs/app-review/).
diff --git a/apps/docs/pages/guides/auth/social-login/auth-figma.mdx b/apps/docs/pages/guides/auth/social-login/auth-figma.mdx
index 1b7ce0b5305..fe9de319ffb 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-figma.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-figma.mdx
@@ -48,6 +48,15 @@ Setting up Figma logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `figma` as the `provider`:
```js
@@ -58,14 +67,51 @@ async function signInWithFigma() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Figma` as the `Provider`:
+
+```kotlin
+suspend fun signInWithFigma() {
+ supabase.gotrue.loginWith(Figma)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-github.mdx b/apps/docs/pages/guides/auth/social-login/auth-github.mdx
index 87236125962..140c06abd4a 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-github.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-github.mdx
@@ -59,24 +59,70 @@ Copy your new OAuth credentials
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `github` as the `provider`:
```js
-async function signInWithGitHub() {
+async function signInWithGithub() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'github',
})
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Github` as the `Provider`:
+
+```kotlin
+suspend fun signInWithGithub() {
+ supabase.gotrue.loginWith(Github)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-gitlab.mdx b/apps/docs/pages/guides/auth/social-login/auth-gitlab.mdx
index 5d4801f4c41..d20d8ab1895 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-gitlab.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-gitlab.mdx
@@ -45,6 +45,15 @@ Setting up GitLab logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `gitlab` as the `provider`:
```js
@@ -55,14 +64,51 @@ async function signInWithGitLab() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Gitlab` as the `Provider`:
+
+```kotlin
+suspend fun signInWithGitLab() {
+ supabase.gotrue.loginWith(Gitlab)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-google.mdx b/apps/docs/pages/guides/auth/social-login/auth-google.mdx
index b066163eefb..292bacbaba1 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-google.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-google.mdx
@@ -29,21 +29,51 @@ Sign in with Google's OAuth flow is designed for web or browser based sign in me
Behind the scenes, Supabase Auth uses the [Google OAuth 2.0 APIs](https://developers.google.com/identity/openid-connect/openid-connect), which are OpenID Connect certified, to perform the authentication.
-To initiate sign in, you can use the `signInWithOAuth()` method from the Supabase JavaScript library:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
-```ts
+```js
supabase.auth.signInWithOAuth({
provider: 'google',
})
```
+To initiate sign in, you can use the `signInWithOAuth()` method from the Supabase JavaScript library:
+
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.loginWith(Google)
+```
+
+To initiate sign in, you can use the `loginWith()` method from the Supabase JavaScript library:
+
+</TabPanel>
+</Tabs>
+
This call takes the user to Google's consent screen. When the flow ends, the user's profile information is exchanged and validated with Supabase Auth before it redirects back to your web application with an access and refresh token representing the user's session.
You can additionally extract the `provider_token` from the session (on initial login only) which is the OAuth 2.0 access token issued by Google that grants your application access to the Google services for the authenticated users. Please store this token in local storage, cookies or in your database or server.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Google does not send out a refresh token by default, so you will need to pass parameters like these to `signInWithOAuth()` in order to extract the `provider_refresh_token`:
-```ts
+```js
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
@@ -55,6 +85,21 @@ const { data, error } = await supabase.auth.signInWithOAuth({
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.loginWith(Google) {
+ queryParams["access_type"] = "offline"
+ queryParams["prompt"] = "consent"
+}
+```
+
+To initiate sign in, you can use the `loginWith()` method from the Supabase JavaScript library:
+
+</TabPanel>
+</Tabs>
+
### Configuration [#configuration-web]
To use the OAuth 2.0 flow, you will require the following information:
@@ -69,9 +114,18 @@ Unlike the OAuth flow which requires the use of a web browser, the native Sign i
When the user provides consent, Google issues an identity token (commonly abbreviated as ID token) that is then sent to your project's Supabase Auth server. When valid, a new user session is started by issuing an access and refresh token from Supabase Auth.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="dart"
+ queryGroup="language"
+>
+<TabPanel id="dart" label="Flutter">
+
If you are building a Flutter app, you can use [flutter_appauth](https://pub.dev/packages/flutter_appauth) package to sign a user into your Supabase project:
-````dart
+```dart
import 'dart:convert';
import 'dart:math';
import 'package:crypto/crypto.dart';
@@ -154,22 +208,67 @@ Future<AuthResponse> signInWithGoogle() {
}
```
+</TabPanel>
+<TabPanel id="js" label="JavaScript">
+
In the Supabase JavaScript library, which you can use with web-based native frameworks like React Native or Expo, you can invoke this functionality like so:
```ts
await supabase.auth.signInWithIdToken({
provider: 'google',
token: '<identity token received from the OS>',
- access_token: '<access token received from the OS>'
+ access_token: '<access token received from the OS>',
})
-````
+```
+
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When using [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform/), you can use the [compose-auth](https://supabase.com/docs/reference/kotlin/installing) plugin. On Android it uses Google OneTap automatically and on other platforms it uses `gotrue.loginWith(Google)`.
+Alternatively, you can have a look at [Google One Tap](https://developers.google.com/identity/one-tap/android/overview), just login with the IdToken after you receive it.
+
+**Initialize the Supabase Client**
+
+**Note:** You have to create OAuth credentials for both a Web and Android application. [Learn more](https://developers.google.com/identity/one-tap/android/get-started#api-console)
+
+```kotlin
+val supabaseClient = createSupabaseClient(
+ supabaseUrl = "SUPABASE_URL",
+ supabaseKey = "SUPABASE_KEY"
+) {
+ install(GoTrue)
+ install(ComposeAuth) {
+ nativeGoogleLogin("WEB_GOOGLE_CLIENT_ID") //Use the Web Client ID, not the Android one!
+ }
+}
+```
+
+**Use the Compose Auth plugin in your Auth Screen**
+
+```kotlin
+val authState = supabaseClient.composeAuth.rememberLoginWithGoogle(
+ onResult = {
+ when(it) { //handle errors
+ NativeSignInResult.ClosedByUser -> TODO()
+ is NativeSignInResult.Error -> TODO()
+ is NativeSignInResult.NetworkError -> TODO()
+ NativeSignInResult.Success -> TODO()
+ }
+ }
+)
+
+Button(onClick = { authState.startFlow() }) {
+ Text("Sign in with Google")
+}
+```
+
+</TabPanel>
+</Tabs>
Please take a look at these open-source projects which may help you obtain an ID token directly from the OS:
- [react-native-google-signin/google-signin](https://github.com/react-native-google-signin/google-signin).
-For apps written in Kotlin, please consult the [community maintained library](/docs/reference/kotlin/introduction).
-
### Configuration [#configuration-native-app]
1. Configure OAuth credentials for your Google Cloud project in the [Credentials](https://console.cloud.google.com/apis/credentials) page of the console. When creating a new OAuth client ID, choose _Android_ or _iOS_ depending on the mobile operating system your app is built for.
diff --git a/apps/docs/pages/guides/auth/social-login/auth-kakao.mdx b/apps/docs/pages/guides/auth/social-login/auth-kakao.mdx
index 8a340236826..f4fabf24822 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-kakao.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-kakao.mdx
@@ -70,6 +70,15 @@ This will serve as the `client_id` when you make API calls to authenticate the u
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `kakao` as the `provider`:
```js
@@ -80,14 +89,51 @@ async function signInWithKakao() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Kakao` as the `Provider`:
+
+```kotlin
+suspend fun signInWithKakao() {
+ supabase.gotrue.loginWith(Kakao)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Kakao Developers Portal](https://developers.kakao.com).
diff --git a/apps/docs/pages/guides/auth/social-login/auth-keycloak.mdx b/apps/docs/pages/guides/auth/social-login/auth-keycloak.mdx
index b0078e6cfae..4c05ec6f1c7 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-keycloak.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-keycloak.mdx
@@ -61,6 +61,15 @@ Under the "Credentials" tab, the `Secret` value will be used as the `client secr
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `keycloak` as the `provider`:
```js
@@ -74,14 +83,53 @@ async function signInWithKeycloak() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Keycloak` as the `Provider`:
+
+```kotlin
+suspend fun signInWithKeycloak() {
+ supabase.gotrue.loginWith(Keycloak) {
+ scopes.add("openid")
+ }
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- You can find the keycloak openid endpoint configuration under the realm settings.
diff --git a/apps/docs/pages/guides/auth/social-login/auth-linkedin.mdx b/apps/docs/pages/guides/auth/social-login/auth-linkedin.mdx
index d885fb8644f..190c4738dae 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-linkedin.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-linkedin.mdx
@@ -50,6 +50,15 @@ Setting up LinkedIn logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `linkedin` as the `provider`:
```js
@@ -60,14 +69,51 @@ async function signInWithLinkedIn() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `LinkedIn` as the `Provider`:
+
+```kotlin
+suspend fun signInWithKaLinkedIn() {
+ supabase.gotrue.loginWith(LinkedIn)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-notion.mdx b/apps/docs/pages/guides/auth/social-login/auth-notion.mdx
index df59c508485..94c95bbe19b 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-notion.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-notion.mdx
@@ -48,6 +48,15 @@ Setting up Notion logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `notion` as the `provider`:
```js
@@ -58,14 +67,51 @@ async function signInWithNotion() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Notion` as the `Provider`:
+
+```kotlin
+suspend fun signInWithNotion() {
+ supabase.gotrue.loginWith(Notion)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-slack.mdx b/apps/docs/pages/guides/auth/social-login/auth-slack.mdx
index 48859c3a5ca..2f9539d049d 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-slack.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-slack.mdx
@@ -60,6 +60,15 @@ Under `Scopes`:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `slack` as the `provider`:
```js
@@ -70,14 +79,51 @@ async function signInWithSlack() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Slack` as the `Provider`:
+
+```kotlin
+suspend fun signInWithSlack() {
+ supabase.gotrue.loginWith(Slack)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-spotify.mdx b/apps/docs/pages/guides/auth/social-login/auth-spotify.mdx
index f65374571f1..9ffe50ab4f3 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-spotify.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-spotify.mdx
@@ -52,6 +52,15 @@ Under `Redirect URIs`:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `spotify` as the `provider`:
```js
@@ -62,14 +71,51 @@ async function signInWithSpotify() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Spotify` as the `Provider`:
+
+```kotlin
+suspend fun signInWithSpotify() {
+ supabase.gotrue.loginWith(Spotify)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-twitch.mdx b/apps/docs/pages/guides/auth/social-login/auth-twitch.mdx
index 6b4951f880d..a5a0daf4d10 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-twitch.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-twitch.mdx
@@ -63,6 +63,15 @@ Setting up Twitch logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `twitch` as the `provider`:
```js
@@ -73,14 +82,51 @@ async function signInWithTwitch() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Twitch` as the `Provider`:
+
+```kotlin
+suspend fun signInWithTwitch() {
+ supabase.gotrue.loginWith(Twitch)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-twitter.mdx b/apps/docs/pages/guides/auth/social-login/auth-twitter.mdx
index 381e453bb3b..dac1daefa75 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-twitter.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-twitter.mdx
@@ -53,6 +53,15 @@ Setting up Twitter logins for your application consists of 3 parts:
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `twitter` as the `provider`:
```js
@@ -63,14 +72,51 @@ async function signInWithTwitter() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Twitter` as the `Provider`:
+
+```kotlin
+suspend fun signInWithTwitter() {
+ supabase.gotrue.loginWith(Twitter)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-workos.mdx b/apps/docs/pages/guides/auth/social-login/auth-workos.mdx
index 4df551be6e4..29c0a8de326 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-workos.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-workos.mdx
@@ -52,6 +52,15 @@ You can pick between any one of the many identity providers that WorkOS supports
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `workos` as the `provider`:
```js
@@ -71,14 +80,57 @@ async function signInWithWorkOS() {
Refer to the [WorkOS Documentation](https://workos.com/docs/reference/sso/authorize/) to learn more about the different methods.
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `WorkOS` as the `Provider`:
+
+```kotlin
+suspend fun signInWithWorkOS() {
+ supabase.gotrue.loginWith(WorkOS) {
+ queryParams["connection"] = "<your_connection>"
+ queryParams["organization"] = "<your_organization>"
+ queryParams["provider"] = "<your_provider>"
+ }
+}
+```
+
+Refer to the [WorkOS Documentation](https://workos.com/docs/reference/sso/authorize/) to learn more about the different methods.
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [WorkOS Documentation](https://workos.com/docs/sso/guide)
diff --git a/apps/docs/pages/guides/auth/social-login/auth-zoom.mdx b/apps/docs/pages/guides/auth/social-login/auth-zoom.mdx
index 9e2f9792dcc..2599249edb4 100644
--- a/apps/docs/pages/guides/auth/social-login/auth-zoom.mdx
+++ b/apps/docs/pages/guides/auth/social-login/auth-zoom.mdx
@@ -61,6 +61,15 @@ Under `Scopes`
## Add login code to your client app
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `zoom` as the `provider`:
```js
@@ -71,14 +80,51 @@ async function signInWithZoom() {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs in, call [loginWith(Provider)](/docs/reference/kotlin/auth-signinwithoauth) with `Zoom` as the `Provider`:
+
+```kotlin
+suspend fun signInWithZoom() {
+ supabase.gotrue.loginWith(Zoom)
+}
+```
+
+</TabPanel>
+</Tabs>
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:
```js
-async function signout() {
+async function signOut() {
const { error } = await supabase.auth.signOut()
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+When your user signs out, call [logout()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:
+
+```kotlin
+suspend fun signOut() {
+ supabase.gotrue.logout()
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resources
- [Supabase Account - Free Plan OK](https://supabase.com)
diff --git a/apps/docs/pages/guides/auth/sso/auth-sso-saml.mdx b/apps/docs/pages/guides/auth/sso/auth-sso-saml.mdx
index 0c30361e566..4116d445b6f 100644
--- a/apps/docs/pages/guides/auth/sso/auth-sso-saml.mdx
+++ b/apps/docs/pages/guides/auth/sso/auth-sso-saml.mdx
@@ -185,7 +185,16 @@ Once you've added an identity provider, users who have access to it can sign in
To initiate a sign-in request from your application's user interface (i.e. the SP Initiated Flow), you can use:
-```typescript
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
+```js
supabase.auth.signInWithSSO({
domain: 'company.com',
})
@@ -193,6 +202,18 @@ supabase.auth.signInWithSSO({
Calling [`signInWithSSO`](/docs/reference/javascript/auth-signinwithsso) starts the sign-in process using the identity provider registered for the `company.com` domain name. It is not required that identity providers be assigned one or multiple domain names, in which case you can use the provider's unique ID instead.
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+supabase.gotrue.loginWith(SSO.withDomain("company.com"))
+```
+
+Calling [`loginWith(SSO)`](/docs/reference/kotlin/auth-signinwithsso) starts the sign-in process using the identity provider registered for the `company.com` domain name. It is not required that identity providers be assigned one or multiple domain names, in which case you can use the provider's unique ID instead.
+
+</TabPanel>
+</Tabs>
+
### Understanding attribute mappings
When a user signs in using the SAML 2.0 Single Sign-On protocol, an XML document called the SAML Assertion is exchanged between the identity provider and Supabase Auth.
diff --git a/apps/docs/pages/guides/realtime/broadcast.mdx b/apps/docs/pages/guides/realtime/broadcast.mdx
index 01c49dc3f3f..d416cbe245a 100644
--- a/apps/docs/pages/guides/realtime/broadcast.mdx
+++ b/apps/docs/pages/guides/realtime/broadcast.mdx
@@ -17,6 +17,15 @@ You can use the Supabase client libraries to send and receive Broadcast messages
Go to your Supabase project's [API Settings](https://supabase.com/dashboard/project/_/settings/api) and grab the `URL` and `anon` public API key.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
import { createClient } from '@supabase/supabase-js'
@@ -26,10 +35,33 @@ const SUPABASE_KEY = '<your-anon-key>'
const client = createClient(SUPABASE_URL, SUPABASE_KEY)
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val supabaseUrl = "https://<project>.supabase.co"
+val supabaseKey = "<your-anon-key>"
+val client = createSupabaseClient(supabaseUrl, supabaseKey) {
+ install(Realtime)
+}
+```
+
+</TabPanel>
+</Tabs>
+
### Listening to Broadcast messages
You can provide a callback for the `broadcast` channel to receive message. In this example we will receive any `broadcast` messages in `room-1`:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
{/* prettier-ignore */}
```js
// Join a room/topic. Can be anything except for 'realtime'.
@@ -50,8 +82,37 @@ channelA
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val channelA = clientA.realtime.createChannel("room-1")
+
+//Listen for broadcast messages
+val broadcastFlow: Flow<JsonObject> = channelA.broadcastFlow<JsonObject>("test")
+ .onEach {
+ println(it)
+ }
+ .launchIn(yourCoroutineScope) //you can also use .collect { } here
+
+clientA.realtime.connect()
+channelA.join()
+```
+
+</TabPanel>
+</Tabs>
+
### Sending Broadcast messages
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
We can send Broadcast messages using `channelB.send()`. Let's set up another client to send messages.
{/* prettier-ignore */}
@@ -74,6 +135,27 @@ channelB.subscribe((status) => {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+We can send Broadcast messages using `channelB.broadcast()`. Let's set up another client to send messages.
+
+```kotlin
+val channelB = clientA.realtime.createChannel("room-1")
+
+clientA.realtime.connect()
+
+channelB.join(blockUntilJoined = true) //You can also use the channelA.status flow instead, but this parameter will block the coroutine until the status is joined.
+
+channelB.broadcast(
+ event = "test",
+ payload = YourMessage(message = "hello, world!")
+)
+```
+
+</TabPanel>
+</Tabs>
+
Before sending messages we need to ensure the client is connected, which we have done within the `subscribe()` callback.
## Broadcast options
@@ -82,6 +164,15 @@ You can pass configuration options while initializing the Supabase Client.
### Self-send messages
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
By default, broadcast messages are only sent to other clients. You can broadcast messages back to the sender by setting Broadcast's `self` parameter to `true`.
{/* prettier-ignore */}
@@ -108,8 +199,49 @@ myChannel.subscribe((status) => {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+By default, broadcast messages are only sent to other clients. You can broadcast messages back to the sender by setting Broadcast's `receiveOwnBroadcasts` parameter to `true`.
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("room-2") {
+ broadcast {
+ receiveOwnBroadcasts = true
+ }
+}
+
+val broadcastFlow: Flow<JsonObject> = myChannel.broadcastFlow<JsonObject>("test-my-messages")
+ .onEach {
+ println(it)
+ }
+ .launchIn(yourCoroutineScope)
+
+clientA.realtime.connect()
+myChannel.join(blockUntilJoined = true) //You can also use the myChannel.status flow instead, but this parameter will block the coroutine until the status is joined.
+
+myChannel.broadcast(
+ event = "test-my-messages",
+ payload = YourMessage(
+ message = "talking to myself"
+ )
+)
+```
+
+</TabPanel>
+</Tabs>
+
### Acknowledge messages
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
You can confirm that Realtime received your message by setting Broadcast's `ack` config to `true`.
{/* prettier-ignore */}
@@ -133,6 +265,27 @@ myChannel.subscribe(async (status) => {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+By default, broadcast messages are only sent to other clients. You can broadcast messages back to the sender by setting Broadcast's `acknowledgeBroadcasts` parameter to `true`.
+
+```kotlin
+ val myChannel = supabase.realtime.createChannel("room-2") {
+ broadcast {
+ acknowledgeBroadcasts = true
+ }
+ }
+
+ supabase.realtime.connect()
+ myChannel.join(blockUntilJoined = true) //You can also use the myChannel.status flow instead, but this parameter will block the coroutine until the status is joined.
+
+ myChannel.broadcast(event = "acknowledge", buildJsonObject { })
+```
+
+</TabPanel>
+</Tabs>
+
Use this to guarantee that the server has received the message before resolving `channelD.send`'s promise. If the `ack` config is not set to `true` when creating the channel, the promise returned by `channelD.send` will resolve immediately.
### Send messages using REST calls
diff --git a/apps/docs/pages/guides/realtime/postgres-changes.mdx b/apps/docs/pages/guides/realtime/postgres-changes.mdx
index 6d4665e4de8..01398116e29 100644
--- a/apps/docs/pages/guides/realtime/postgres-changes.mdx
+++ b/apps/docs/pages/guides/realtime/postgres-changes.mdx
@@ -202,6 +202,15 @@ You can use the Supabase client libraries to subscribe to database changes.
Subscribe to specific schema events using the `schema` parameter:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
{/* prettier-ignore */}
```js
const changes = client
@@ -217,10 +226,44 @@ const changes = client
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("schema-db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction>(schema = "public")
+
+changes
+ .onEach {
+ when(it) { //You can also check for <is PostgresAction.Insert>, etc.. manually
+ is HasRecord -> println(it.record)
+ is HasOldRecord -> println(it.oldRecord)
+ else -> println(it)
+ }
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
The channel name can be any string except 'realtime'.
### Listening to INSERT events
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Use the `event` parameter to listen only to database `INSERT`s:
```js
@@ -237,10 +280,42 @@ const changes = client
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Use `PostgresAction.Insert` as type to listen only to database `INSERT`s:
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public")
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
The channel name can be any string except 'realtime'.
### Listening to UPDATE events
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Use the `event` parameter to listen only to database `UPDATE`s:
```js
@@ -257,11 +332,43 @@ const changes = client
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Use `PostgresAction.Update` as type to listen only to database `UPDATE`s:
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public")
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
The channel name can be any string except 'realtime'.
### Listening to DELETE events
-Use the `event` parameter to listen only to database `UPDATE`s:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
+Use the `event` parameter to listen only to database `DELETE`s:
```js
const changes = client
@@ -277,12 +384,44 @@ const changes = client
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Use `PostgresAction.Delete` as type to listen only to database `DELETE`s:
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Delete>(schema = "public")
+
+changes
+ .onEach {
+ println(it.oldRecord)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
The channel name can be any string except 'realtime'.
### Listening to specific tables
Subscribe to specific table events using the `table` parameter:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const changes = client
.channel('table-db-changes')
@@ -298,12 +437,44 @@ const changes = client
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction>(schema = "public") {
+ table = "todos"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
The channel name can be any string except 'realtime'.
### Listening to multiple changes
To listen to different events and schema/tables/filters combinations with the same channel:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('db-changes')
@@ -328,10 +499,37 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+val messageChanges = myChannel.postgresChangeFlow<PostgresAction>(schema = "public") {
+ table = "messages"
+}
+val userChanges = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
+ table = "users"
+}
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
### Filtering for specific changes
Use the `filter` parameter for granular changes:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const changes = client
.channel('table-filter-changes')
@@ -348,6 +546,30 @@ const changes = client
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
+ table = "todos"
+ filter = "id=eq.1"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
## Available filters
Realtime offers filters so you can specify the data your client receives at a more granular level.
@@ -356,6 +578,15 @@ Realtime offers filters so you can specify the data your client receives at a mo
To listen to changes when a column's value in a table equals a client-specified value:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('changes')
@@ -372,6 +603,30 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
+ table = "messages"
+ filter = "body=eq.hey"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
This filter uses Postgres's `=` filter.
### Not equal to (neq)
@@ -400,6 +655,15 @@ This filter uses Postgres's `!=` filter.
To listen to changes when a column's value in a table is less than a client-specified value:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('changes')
@@ -408,20 +672,53 @@ const channel = supabase
{
event: 'INSERT',
schema: 'public',
- table: 'messages',
- filter: 'id=lt.100',
+ table: 'profiles',
+ filter: 'age=lt.65',
},
(payload) => console.log(payload)
)
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {
+ table = "profiles"
+ filter = "age=lt.65"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
This filter uses Postgres's `<` filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.
### Less than or equal to (lte)
To listen to changes when a column's value in a table is less than or equal to a client-specified value:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('changes')
@@ -438,12 +735,45 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
+ table = "profiles"
+ filter = "age=lte.65"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
This filter uses Postgres' `<=` filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.
### Greater thank (gt)
To listen to changes when a column's value in a table is greater than a client-specified value:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('changes')
@@ -460,12 +790,45 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
+ table = "products"
+ filter = "quantity=gt.10"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
This filter uses Postgres's `>` filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.
### Greater than or equal to (gte)
To listen to changes when a column's value in a table is greater than or equal to a client-specified value:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('changes')
@@ -482,12 +845,45 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
+ table = "products"
+ filter = "quantity=gte.10"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
This filter uses Postgres's `>=` filter, so it works for non-numeric types. Make sure to check the expected behavior of the compared data's type.
### Contained in list (in)
To listen to changes when a column's value in a table equals any client-specified values:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const channel = supabase
.channel('changes')
@@ -504,6 +900,30 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
+ table = "products"
+ filter = "name=in.(red, blue, yellow)"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
This filter uses Postgres's `= ANY`. Realtime allows a maximum of 100 values for this filter.
## Receiving `old` records
@@ -548,6 +968,15 @@ Your project JWT secret is found with your [Project API keys](https://app.supaba
To use your own JWT with Realtime make sure to set the token after instantiating the Supabase client and before connecting to a Channel.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const { createClient } = require('@supabase/supabase-js')
@@ -571,10 +1000,48 @@ const channel = supabase
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val supabase = createSupabaseClient(supabaseUrl, supabaseKey) {
+ install(Realtime) {
+ jwtToken = "your-custom-jwt"
+ }
+}
+val myChannel = supabase.realtime.createChannel("db-changes")
+
+val changes = myChannel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {
+ table = "products"
+ filter = "name=in.(red, blue, yellow)"
+}
+
+changes
+ .onEach {
+ println(it.record)
+ }
+ .launchIn(yourCoroutineScope)
+
+supabase.realtime.connect()
+myChannel.join()
+```
+
+</TabPanel>
+</Tabs>
+
### Refreshed tokens
You will need to refresh tokens on your own, but once generated, you can pass them to Realtime.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
For example, if you're using the `supabase-js` `v2` client then you can pass your token like this:
```js
@@ -583,6 +1050,18 @@ For example, if you're using the `supabase-js` `v2` client then you can pass you
supabase.realtime.setAuth('fresh-token')
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+In Kotlin, you have to update the token manually per channel:
+
+```kotlin
+myChannel.updateAuth("fresh-token")
+```
+
+</TabPanel>
+</Tabs>
+
## Limitations
Realtime systems usually require forethought because of their scaling dynamics. For the `Postgres Changes` feature, every change event must be checked to see if the subscribed user has access. For instance, if you have 100 users subscribed to a table where you make a single insert, it will then trigger 100 "reads": one for each user.
diff --git a/apps/docs/pages/guides/realtime/presence.mdx b/apps/docs/pages/guides/realtime/presence.mdx
index 2b9c271feec..d5c72e17349 100644
--- a/apps/docs/pages/guides/realtime/presence.mdx
+++ b/apps/docs/pages/guides/realtime/presence.mdx
@@ -18,17 +18,49 @@ You can use the Supabase client libraries to track Presence state between users.
Go to your Supabase project's [API Settings](https://supabase.com/dashboard/project/_/settings/api) and grab the `URL` and `anon` public API key.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
import { createClient } from '@supabase/supabase-js'
const SUPABASE_URL = 'https://<project>.supabase.co'
const SUPABASE_KEY = '<your-anon-key>'
-const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
+const client = createClient(SUPABASE_URL, SUPABASE_KEY)
+```
+
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val supabaseUrl = "https://<project>.supabase.co"
+val supabaseKey = "<your-anon-key>"
+val client = createSupabaseClient(supabaseUrl, supabaseKey) {
+ install(Realtime)
+}
```
+</TabPanel>
+</Tabs>
+
### Sync and track state
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Listen to the `sync`, `join`, and `leave` events triggered whenever any client joins or leaves the channel or changes their slice of state:
```js
@@ -48,10 +80,40 @@ roomOne
.subscribe()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Listen to the presence change flow, emitting new a new `PresenceAction` whenever someone joins or leaves:
+
+```kotlin
+val roomOne = supabase.realtime.createChannel("room_01")
+val presenceFlow: Flow<PresenceAction> = roomOne.presenceChangeFlow()
+presenceFlow
+ .onEach {
+ println(it.joins) //You can also use it.decodeJoinsAs<YourType>()
+ println(it.leaves) //You can also use it.decodeLeavesAs<YourType>()
+ }
+ .launchIn(yourCoroutineScope) //You can also use .collect { } here
+supabase.realtime.connect()
+roomOne.join()
+```
+
+</TabPanel>
+</Tabs>
+
### Sending state
You can send state to all subscribers using `track()`:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
{/* prettier-ignore */}
```js
const roomOne = supabase.channel('room_01')
@@ -69,12 +131,41 @@ roomOne.subscribe(async (status) => {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val roomOne = supabase.realtime.createChannel("room_01")
+
+val userStatus = UserStatus( //Your custom class
+ user = "user-1",
+ onlineAt = Clock.System.now().toEpochMilliseconds()
+)
+
+supabase.realtime.connect()
+roomOne.join(blockUntilJoined = true) //You can also use the roomOne.status flow instead, but this parameter will block the coroutine until the status is joined.
+
+roomOne.track(userStatus)
+```
+
+</TabPanel>
+</Tabs>
+
A client will receive state from any other client that is subscribed to the same topic (in this case `room_01`). It will also automatically trigger its own `sync` and `join` event handlers.
### Stop tracking
You can stop tracking precense using the `untrack()` method. This will trigger the `sync` and `leave` event handlers.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
const untrackPresence = async () => {
const presenceUntrackStatus = await roomOne.untrack()
@@ -84,6 +175,20 @@ const untrackPresence = async () => {
untrackPresence()
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+suspend fun untrackPresence() {
+ roomOne.untrack()
+}
+
+untrackPresence()
+```
+
+</TabPanel>
+</Tabs>
+
## Presence options
You can pass configuration options while initializing the Supabase Client.
@@ -92,6 +197,15 @@ You can pass configuration options while initializing the Supabase Client.
By default, Presence will generate a unique `UUIDv1` key on the server to track a client channel's state. If you prefer, you can provide a custom key when creating the channel. This key should be unique among clients.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```js
import { createClient } from '@supabase/supabase-js'
@@ -104,6 +218,20 @@ const channelC = supabase.channel('test', {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val channelC = supabase.realtime.createChannel("test") {
+ presence {
+ key = "userId-123"
+ }
+}
+```
+
+</TabPanel>
+</Tabs>
+
export const Page = ({ children }) => <Layout meta={meta} children={children} />
export default Page
diff --git a/apps/docs/pages/guides/storage/image-transformations.mdx b/apps/docs/pages/guides/storage/image-transformations.mdx
index 35ae84b840c..f050a27fd1f 100644
--- a/apps/docs/pages/guides/storage/image-transformations.mdx
+++ b/apps/docs/pages/guides/storage/image-transformations.mdx
@@ -17,6 +17,15 @@ Supabase Storage offers the functionality to transform and resize images dynamic
## Get a public URL for a transformed image
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
You can pass a `transform` option to the functions you are currently using to interact with your objects. This returns the public URL that serves the resized image.
```ts
@@ -28,6 +37,18 @@ supabase.storage.from('bucket').getPublicUrl('image.jpg', {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val url = supabase.storage["bucket"].publicRenderUrl("image.jpg") {
+ size(width = 500, height = 600)
+}
+```
+
+</TabPanel>
+</Tabs>
+
An example URL could look like this:
`https://project_id.supabase.co/storage/v1/render/image/public/bucket/image.jpg?width=500&height=600`
@@ -36,6 +57,15 @@ An example URL could look like this:
To share a transformed image for a fixed amount of time, provide the transform options when you create the signed URL:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```ts
supabase.storage.from('bucket').createSignedUrl('image.jpg', 60000, {
transform: {
@@ -45,12 +75,33 @@ supabase.storage.from('bucket').createSignedUrl('image.jpg', 60000, {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val url = supabase.storage["bucket"].createSignedUrl("image.jpg", 60.seconds) {
+ size(200, 200)
+}
+```
+
+</TabPanel>
+</Tabs>
+
The transformation options are embedded into the token—they cannot be changed once signed.
## Downloading images
To download a transformed image, pass the `transform` option to the `download` function.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```ts
supabase.storage.from('bucket').download('image.jpg', {
transform: {
@@ -60,6 +111,24 @@ supabase.storage.from('bucket').download('image.jpg', {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val data = supabase.storage["bucket"].downloadAuthenticated("image.jpg") {
+ size(800, 300)
+}
+
+//Or on JVM stream directly to a file
+val file = File("image.jpg")
+supabase.storage["bucket"].downloadAuthenticatedTo("image.jpg", file) {
+ size(800, 300)
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Automatic Image Optimisation (WebP)
When using the image transformation API we will automatically find the best format supported by the browser and return that to the client, without any code change. For instance, if you use Chrome when viewing a jpeg image and using transformation options, you'll see that the content-type returned is `webp`.
@@ -74,6 +143,15 @@ As a result, this will lower the bandwidth that you send to your users and your
In case you'd like to return the original format of the image and **opt-out** from the automatic image optimization detection, you can pass the `format=origin` parameter when requesting a transformed image, this is also supported in the JavaScript SDK starting from v2.2.0
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```ts
await storage.from('bucket').download('image.jpeg', {
transform: {
@@ -84,6 +162,26 @@ await storage.from('bucket').download('image.jpeg', {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val data = supabase.storage["bucket"].downloadAuthenticated("image.jpg") {
+ size(200, 200)
+ format = "origin"
+}
+
+//Or on JVM stream directly to a file
+val file = File("image.jpg")
+supabase.storage["bucket"].downloadAuthenticatedTo("image.jpg", file) {
+ size(200, 200)
+ format = "origin"
+}
+```
+
+</TabPanel>
+</Tabs>
+
## NextJS Loader
You can use Supabase Image Transformation to optimise your NextJS images using a custom [Loader](https://nextjs.org/docs/api-reference/next/image#loader-configuration).
@@ -143,6 +241,15 @@ Use the `resize` parameter with one of the following values:
Example:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```ts
supabase.storage.from('bucket').download('image.jpg', {
transform: {
@@ -153,6 +260,26 @@ supabase.storage.from('bucket').download('image.jpg', {
})
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val data = supabase.storage["bucket"].downloadAuthenticated("image.jpg") {
+ size(800, 300)
+ resize = ImageTransformation.Resize.CONTAIN
+}
+
+//Or on JVM stream directly to a file
+val file = File("image.jpg")
+supabase.storage["bucket"].downloadAuthenticatedTo("image.jpg", file) {
+ size(800, 300)
+ resize = ImageTransformation.Resize.CONTAIN
+}
+```
+
+</TabPanel>
+</Tabs>
+
### Limits
- Width and height must be an integer value between 1-2500.
diff --git a/apps/docs/pages/guides/storage/uploads.mdx b/apps/docs/pages/guides/storage/uploads.mdx
index be7686bff23..6fbc1c39574 100644
--- a/apps/docs/pages/guides/storage/uploads.mdx
+++ b/apps/docs/pages/guides/storage/uploads.mdx
@@ -25,6 +25,15 @@ It uses the traditional `multipart/form-data` format and is simple to implement
reliability.
</Admonition>
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
```javascript
import { createClient } from '@supabase/supabase-js'
@@ -42,6 +51,27 @@ async function uploadFile(file) {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+```kotlin
+val supabase = createSupabaseClient(supabaseUrl, supabaseKey) {
+ install(Storage)
+}
+
+suspend fun uploadData(bytes: ByteArray) {
+ supabase.storage["bucket_name"].upload("file_path", bytes)
+}
+
+//Or on JVM/Android: (This will stream the data from the file to supabase)
+suspend fun uploadFile(file: File) {
+ supabase.storage["bucket_name"].upload("file_path", file)
+}
+```
+
+</TabPanel>
+</Tabs>
+
## Resumable Upload
<Admonition type="note">
@@ -53,6 +83,15 @@ The Resumable upload method is recommended for uploading large files that may ex
Supabase Storage implements the [TUS protocol](https://tus.io/) to enable resumable uploads. TUS stands for The Upload Server and is an open protocol for supporting resumable uploads. The protocol allows the upload process to be resumed from where it left off in case of interruptions. This method can be implemented using the tus-js-client library, or other client-side libraries like [Uppy-js](https://uppy.io/docs/tus/) that support the TUS protocol.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+<TabPanel id="js" label="JavaScript">
+
Here's an example of how to upload a file using `tus-js-client`:
```javascript
@@ -109,6 +148,42 @@ async function uploadFile(bucketName, fileName, file) {
}
```
+</TabPanel>
+<TabPanel id="kotlin" label="Kotlin">
+
+Kotlin supports resumable uploads natively for all targets:
+
+```kotlin
+//Or on JVM/Android: (This will stream the data from the file to supabase)
+suspend fun uploadFile(file: File) {
+ val upload: ResumableUpload = supabase.storage["bucket_name"].resumable.createOrContinueUpload("file_path", file)
+
+ upload.stateFlow
+ .onEach {
+ println(it.progress)
+ }
+ .launchIn(yourCoroutineScope)
+
+ upload.startOrResumeUploading()
+}
+
+//On other platforms you might have to give the bytes directly and specify a source if you want to continue it alter:
+suspend fun uploadData(bytes: ByteArray) {
+ val upload: ResumableUpload = supabase.storage["bucket_name"].resumable.createOrContinueUpload(bytes, "source", "file_path")
+
+ upload.stateFlow
+ .onEach {
+ println(it.progress)
+ }
+ .launchIn(yourCoroutineScope)
+
+ upload.startOrResumeUploading()
+}
+```
+
+</TabPanel>
+</Tabs>
+
### Upload URL
When uploading using the resumable upload endpoint, the TUS server creates a unique URL for each upload, even for multiple uploads to the same path. All chunks will be uploaded to this URL using the `PATCH` method.