Initializing
Create a new client for use in the browser.
You can initialize Supabase with the static initialize()
method of Supabase
class.
The Supabase client is your entrypoint to the rest of the Supabase functionality and is the easiest way to interact with everything we offer within the Supabase ecosystem.
Parameters
- supabaseUrlREQUIREDstring
The unique Supabase URL which is supplied when you create a new project in your project dashboard.
- supabaseKeyREQUIREDstring
The unique Supabase Key which is supplied when you create a new project in your project dashboard.
- optionsOptionalSupabaseClientOptionsauthOptionalobjectautoRefreshTokenOptionalboolean
Automatically refreshes the token for logged-in users. Defaults to true.
detectSessionInUrlOptionalbooleanDetect a session from the URL. Used for OAuth login callbacks. Defaults to true.
flowTypeOptionalobjectOAuth flow to use - defaults to implicit flow. PKCE is recommended for mobile and server-side applications.
persistSessionOptionalbooleanWhether to persist a logged-in session to storage. Defaults to true.
storageOptionalobjectA storage provider. Used to store the logged-in session.
storageKeyOptionalstringOptional key name used for storing tokens in local storage.
dbOptionalobjectThe Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to `public`.
schemaOptionalSchemaNameglobalOptionalobjectfetchOptionalFetchA custom `fetch` implementation.
headersOptionalRecordOptional headers for initializing the client.
realtimeOptionalRealtimeClientOptionsOptions passed to the realtime-js instance
Future<void> main() async {
await Supabase.initialize(
url: 'https://xyzcompany.supabase.co',
anonKey: 'public-anon-key',
);
runApp(MyApp());
}
// Get a reference your Supabase client
final supabase = Supabase.instance.client;