Skip to content

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

feat: update auth doc for dart v1-dev

dshukertjr8d32543d9968
diff --git a/apps/reference/_supabase_dart/generated/auth-session.mdx b/apps/reference/_supabase_dart/generated/auth-session.mdx
index 1ca53e7ece4..b15acf2435f 100644
--- a/apps/reference/_supabase_dart/generated/auth-session.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-session.mdx
@@ -11,7 +11,7 @@ import TabItem from '@theme/TabItem'
Returns the session data, if there is an active session.
```dart
-final session = supabase.auth.session();
+final session = supabase.auth.currentSession;
```
## Examples
@@ -19,5 +19,5 @@ final session = supabase.auth.session();
### Get the session data
```dart
-final session = supabase.auth.session();
+final session = supabase.auth.currentSession;
```
diff --git a/apps/reference/_supabase_dart/generated/auth-signin.mdx b/apps/reference/_supabase_dart/generated/auth-signin.mdx
index 639c2b47b27..fb17e0bbb7a 100644
--- a/apps/reference/_supabase_dart/generated/auth-signin.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-signin.mdx
@@ -11,10 +11,13 @@ import TabItem from '@theme/TabItem'
Log in an existing user, or login via a third-party provider.
```dart
-final res = await supabase.auth.signIn(email: '[email protected]', password: 'example-password');
+try {
+ final res = await supabase.auth.signIn(email: '[email protected]', password: 'example-password');
-final user = res.data?.user;
-final error = res.error;
+ final user = res.user;
+} catch (error) {
+ // handle error
+}
```
## Notes
@@ -30,10 +33,13 @@ final error = res.error;
### Sign in with email.
```dart
-final res = await supabase.auth.signIn(email: '[email protected]', password: 'example-password');
+try {
+ final res = await supabase.auth.signIn(email: '[email protected]', password: 'example-password');
-final user = res.data?.user;
-final error = res.error;
+ final user = res.user;
+} catch (error) {
+ // handle error
+}
```
### Sign in with magic link.
@@ -41,9 +47,11 @@ final error = res.error;
If email is provided, but no password is provided, the user will be sent a "magic link" to their email address, which they can click to open your application with a valid session. By default, a given user can only request a Magic Link once every 60 seconds.
```dart
-final res = await supabase.auth.signIn(email: '[email protected]');
-
-final error = res.error;
+try {
+ final res = await supabase.auth.signIn(email: '[email protected]');
+} catch (error) {
+ // handle error
+}
```
### Get OAuth sign in URL.
@@ -52,8 +60,11 @@ Passing provider parameter to `signIn()` will return a URL to sign your user in
If you are looking to sign in a user via OAuth on Flutter app, go to [`signInWithProvider()`](/docs/reference/dart/auth-signinwithprovider).
```dart
-final res = await supabase.auth.signIn(provider: Provider.github);
+try {
+ final res = await supabase.auth.signIn(provider: Provider.github);
-final url = res.data?.url;
-final error = res.error;
+ final user = res.user;
+} catch (error) {
+ // handle error
+}
```
diff --git a/apps/reference/_supabase_dart/generated/auth-signinwithprovider.mdx b/apps/reference/_supabase_dart/generated/auth-signinwithprovider.mdx
index c44069bacb6..3ec3127ad61 100644
--- a/apps/reference/_supabase_dart/generated/auth-signinwithprovider.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-signinwithprovider.mdx
@@ -11,9 +11,11 @@ import TabItem from '@theme/TabItem'
Signs the user in using third party OAuth providers.
```dart
-final res = await supabase.auth.signInWithProvider(Provider.github);
-
-final error = res.error;
+try {
+ await supabase.auth.signInWithProvider(Provider.github);
+} catch (error) {
+ // handle error
+}
```
## Notes
@@ -26,9 +28,11 @@ final error = res.error;
### Sign in with provider.
```dart
-final res = await supabase.auth.signInWithProvider(Provider.github);
-
-final error = res.error;
+try {
+ await supabase.auth.signInWithProvider(Provider.github);
+} catch (error) {
+ // handle error
+}
```
### With `redirectTo`
@@ -37,15 +41,14 @@ Specify the redirect link to bring back the user via deeplink.
Note that `redirectTo` should be null for Flutter Web.
```dart
-final res = await supabase.auth.signInWithProvider(
- Provider.github,
- options: AuthOptions(
- redirectTo: kIsWeb
- ? null
- : 'io.supabase.flutter://reset-callback/'),
-);
-
-final error = res.error;
+try {
+ await supabase.auth.signInWithProvider(Provider.github,
+ options: const AuthOptions(
+ redirectTo:
+ kIsWeb ? null : 'io.supabase.flutter://reset-callback/'));
+} catch (error) {
+ // handle error
+}
```
### With scopes
@@ -54,10 +57,16 @@ If you need additional data from an OAuth provider, you can include a space-sepa
You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider.
```dart
-const { user, session, error } = await supabase.auth.signIn({
- provider: 'github'
-}, {
- scopes: 'repo gist notifications'
-})
-const oAuthToken = session.provider_token // use to access provider API
+try {
+ await supabase.auth.signInWithProvider(Provider.github,
+ options: const AuthOptions(scopes: 'repo gist notifications'));
+} catch (error) {
+ // handle error
+}
+
+...
+// after user comes back from signin flow
+
+final session = supabase.auth.currentSession;
+final oAuthToken = session?.providerToken;
```
diff --git a/apps/reference/_supabase_dart/generated/auth-signout.mdx b/apps/reference/_supabase_dart/generated/auth-signout.mdx
index 2f05b6435da..b3ba3c9c0ba 100644
--- a/apps/reference/_supabase_dart/generated/auth-signout.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-signout.mdx
@@ -11,9 +11,11 @@ import TabItem from '@theme/TabItem'
Signs out the current user, if there is a logged in user.
```dart
-final res = await supabase.auth.signOut();
-
-final error = res.error;
+try {
+ await supabase.auth.signOut();
+} catch (error) {
+ // handle error
+}
```
## Examples
@@ -21,7 +23,9 @@ final error = res.error;
### Sign out
```dart
-final res = await supabase.auth.signOut();
-
-final error = res.error;
+try {
+ await supabase.auth.signOut();
+} catch (error) {
+ // handle error
+}
```
diff --git a/apps/reference/_supabase_dart/generated/auth-signup.mdx b/apps/reference/_supabase_dart/generated/auth-signup.mdx
index a9a12b7ffc3..13b81be5c3b 100644
--- a/apps/reference/_supabase_dart/generated/auth-signup.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-signup.mdx
@@ -11,10 +11,13 @@ import TabItem from '@theme/TabItem'
Creates a new user.
```dart
-final res = await supabase.auth.signUp('[email protected]', 'example-password');
+try {
+ final res = await supabase.auth.signUp('[email protected]', 'example-password');
-final user = res.data?.user;
-final error = res.error;
+ final user = res.user;
+} catch (error) {
+ // handle error
+}
```
## Notes
@@ -29,10 +32,13 @@ final error = res.error;
### Sign up.
```dart
-final res = await supabase.auth.signUp('[email protected]', 'example-password');
+try {
+ final res = await supabase.auth.signUp('[email protected]', 'example-password');
-final user = res.data?.user;
-final error = res.error;
+ final user = res.user;
+} catch (error) {
+ // handle error
+}
```
### Sign up with third-party providers.
diff --git a/apps/reference/_supabase_dart/generated/auth-update.mdx b/apps/reference/_supabase_dart/generated/auth-update.mdx
index 69b16bd7af8..a9d0c049744 100644
--- a/apps/reference/_supabase_dart/generated/auth-update.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-update.mdx
@@ -11,11 +11,11 @@ import TabItem from '@theme/TabItem'
Updates user data, if there is a logged in user.
```dart
-final res = await supabase.auth.update(
- UserAttributes(data: {'hello': 'world'})
-);
-
-final error = res.error;
+try {
+ final res = await supabase.auth.update(UserAttributes(data: {'hello': 'world'}));
+} catch (error) {
+ // handle error
+}
```
## Notes
@@ -28,9 +28,9 @@ Use the `update()` method if you have data which rarely changes or is specific o
### Update a user's metadata.
```dart
-final res = await supabase.auth.update(
- UserAttributes(data: {'hello': 'world'})
-);
-
-final error = res.error;
+try {
+ final res = await supabase.auth.update(UserAttributes(data: {'hello': 'world'}));
+} catch (error) {
+ // handle error
+}
```
diff --git a/apps/reference/_supabase_dart/generated/auth-user.mdx b/apps/reference/_supabase_dart/generated/auth-user.mdx
index d789a54798a..c813866ab83 100644
--- a/apps/reference/_supabase_dart/generated/auth-user.mdx
+++ b/apps/reference/_supabase_dart/generated/auth-user.mdx
@@ -11,7 +11,7 @@ import TabItem from '@theme/TabItem'
Returns the user data, if there is a logged in user.
```dart
-final user = supabase.auth.user();
+final user = supabase.auth.currentUser;
```
## Examples
@@ -19,5 +19,5 @@ final user = supabase.auth.user();
### Get the logged in user
```dart
-final user = supabase.auth.user();
+final user = supabase.auth.currentUser;
```
diff --git a/apps/reference/_supabase_dart/intro.mdx b/apps/reference/_supabase_dart/intro.mdx
index 29286743efb..7cd08259b4f 100644
--- a/apps/reference/_supabase_dart/intro.mdx
+++ b/apps/reference/_supabase_dart/intro.mdx
@@ -6,6 +6,14 @@ sidebar_label: Supabase Dart Library
# Supabase Dart Library
+:::note
+
+You're viewing the Supabase docs for the next version of our library which is not yet released.
+
+Refer to the `v0` docs for a stable release.
+
+:::
+
This reference documents every object and method available in Supabase's isomorphic Dart library, `supabase-dart`.
You can use the `supabase-dart` library to: