Warning This repository has been moved to the supabase-flutter repo.
A Dart client for Supabase.
Note
If you are developing a Flutter application, use supabase_flutter instead.
supabase
package is for non-Flutter Dart environments.
Supabase is an open source Firebase alternative. We are a service to:
- listen to database changes
- query your tables, including filtering, pagination, and deeply nested relationships (like GraphQL)
- create, update, and delete rows
- manage your users and their permissions
- interact with your database using a simple UI
Public Beta: Stable. No breaking changes expected in this version but possible bugs.
Find the documentation here.
import 'package:supabase/supabase.dart';
main() {
final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
// Select from table `countries` ordering by `name`
final data = await supabase
.from('countries')
.select()
.order('name', ascending: true);
}
import 'package:supabase/supabase.dart';
main() {
final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
// Set up a listener to listen to changes in `countries` table
supabase.channel('my_channel').on(RealtimeListenTypes.postgresChanges, ChannelFilter(
event: '*',
schema: 'public',
table: 'countries'
), (payload, [ref]) {
// Do something when there is an update
}).subscribe();
// remember to remove the channels when you're done
supabase.removeAllChannels();
}
To receive realtime updates, you have to first enable Realtime on from your Supabase console. You can read more here on how to enable it.
import 'package:supabase/supabase.dart';
main() {
final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
// Set up a listener to listen to changes in `countries` table
final subscription = supabase
.from('countries')
.stream(primaryKey: ['id']) // Pass list of primary key column names
.order('name')
.limit(30)
.listen(_handleCountriesStream);
// remember to remove subscription when you're done
subscription.cancel();
}
This package does not persist auth state automatically. Use supabase_flutter for Flutter apps to persist auth state instead of this package.
import 'package:supabase/supabase.dart';
main() {
final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
// Sign up user with email and password
final response = await supabase
.auth
.signUp(email: '[email protected]', password: 'password');
}
import 'package:supabase/supabase.dart';
main() {
final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
// Create file `example.txt` and upload it in `public` bucket
final file = File('example.txt');
file.writeAsStringSync('File content');
final storageResponse = await supabase
.storage
.from('public')
.upload('example.txt', file);
}
Check out the Official Documentation to learn all the other available methods.
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes and merge
This repo is licenced under MIT.