Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 7 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

A Dart client for [Supabase](https://supabase.io/).

> **Note**
>
> If you are developing a Flutter application, use [supabase_flutter](https://pub.dev/packages/supabase_flutter) instead. `supabase` package is for non-Flutter Dart environments.

[![pub package](https://img.shields.io/pub/v/supabase.svg)](https://pub.dev/packages/supabase)
[![pub test](https://github.com/supabase/supabase-dart/workflows/Test/badge.svg)](https://github.com/supabase/supabase-dart/actions?query=workflow%3ATest)

Expand All @@ -26,7 +30,7 @@ A Dart client for [Supabase](https://supabase.io/).

## Docs

`supabase-dart` mirrors the design of `supabase-js`. Find the documentation [here](https://supabase.io/docs/reference/javascript/initializing).
Find the documentation [here](https://supabase.io/docs/reference/dart/initializing).

## Usage example

Expand Down Expand Up @@ -93,6 +97,8 @@ main() {

### [Authentication](https://supabase.io/docs/guides/auth)

This package does not persist auth state automatically. User [supabase_flutter](https://pub.dev/packages/supabase_flutter) for Flutter apps to persist auth state instead of this package.

```dart
import 'package:supabase/supabase.dart';

Expand Down Expand Up @@ -124,62 +130,8 @@ main() {
}
```

## Authentication

Initialize a [`SupabaseClient`](https://supabase.com/docs/reference/dart/initializing#access-supabaseclient-instance) by passing your **Supabase URL** and **Supabase KEY**. The keys can be found in your supabase project in `/setting/API`.

```dart
final client = SupabaseClient('supabaseUrl', 'supabaseKey');
```

The `client` has a [`auth`](https://pub.dev/documentation/supabase/latest/supabase/SupabaseClient/auth.html) attribute (of type [`GoTrueClient`](https://pub.dev/documentation/gotrue/latest/gotrue/GoTrueClient-class.html)) that you can use to authenticate your users using supabase.

### Sign up

Use the [`signUp`](https://supabase.com/docs/reference/dart/auth-signup) method to create a new user account.

```dart
// Sign up user with email and password
final response = await supabase.auth.signUp(email: email, password: password);
final Session? session = response.session;
final User? user = response.user;
```

### Sign in

There are a few ways to sign in a user into your app.

Use the [`signInWithPassword`](https://supabase.com/docs/reference/dart/auth-signinwithpassword) method to sign in a user with their email or phone with password.

```dart
// Sign in user with email and password
final response = await client.auth.signInWithPassword(email: email, password: password);
final Session? session = response.session;
final User? user = response.user;
```

Use the [`signInWithOtp`](https://supabase.com/docs/reference/dart/auth-signinwithotp) method to sign in a user using magic link with email or one time password using phone number.

```dart
// Sign in user with email and password
await client.auth.signInWithOtp(email: email);
```


### Sign out

Use the [`signOut`](https://supabase.com/docs/reference/dart/auth-signout) method to sign out a user.

```dart
// Sign out user
await client.auth.signOut();
```

Check out the [**Official Documentation**](https://supabase.com/docs/reference/dart/) to learn all the other available methods.

## Guides

- Flutter Supabase Authentication - [Blog](https://www.sandromaglione.com/2021/04/24/flutter-supabase-authentication/)

## Contributing

Expand Down