Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

SupabaseClient

Supabase Client.

An isomorphic Javascript client for interacting with Postgres.

class SupabaseClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
constructor(
supabaseUrl: string,
supabaseKey: string,
options?: SupabaseClientOptions<SchemaName>,
);
private _getAccessToken;
private _handleTokenChanged;
private _initRealtimeClient;
private _initSupabaseAuthClient;
private _listenForAuthEvents;
protected authUrl: string;
protected changedAccessToken?: string;
protected fetch?: Fetch;
protected functionsUrl: string;
protected headers: Record<string, string>;
protected realtimeUrl: string;
protected rest: PostgrestClient<Database, SchemaName>;
protected storageKey: string;
protected storageUrl: string;
protected supabaseKey: string;
protected supabaseUrl: string;
auth: SupabaseAuthClient;
get functions(): FunctionsClient;
realtime: RealtimeClient;
get storage(): SupabaseStorageClient;
 
channel(name: string, opts?: RealtimeChannelOptions): RealtimeChannel;
from<TableName extends string & keyof Schema["Tables"], Table extends Schema["Tables"][TableName]>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>;
from<ViewName extends string & keyof Schema["Views"], View extends Schema["Views"][ViewName]>(relation: ViewName): PostgrestQueryBuilder<Schema, View, ViewName>;
getChannels(): RealtimeChannel[];
removeAllChannels(): Promise<("ok" | "timed out" | "error")[]>;
removeChannel(channel: RealtimeChannel): Promise<"ok" | "timed out" | "error">;
rpc<FnName extends string & keyof Schema["Functions"], Fn extends Schema["Functions"][FnName]>(
fn: FnName,
args?: Fn["Args"],
options?: {
head?: boolean;
count?: "exact" | "planned" | "estimated";
}
,
): PostgrestFilterBuilder<Schema, Fn["Returns"] extends any[] ? Fn["Returns"][number] extends Record<string, unknown> ? Fn["Returns"][number] : never : never, Fn["Returns"]>;
schema<DynamicSchema extends string & keyof Database>(schema: DynamicSchema): PostgrestClient<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>;
}

§Type Parameters

§
Database = any
[src]
§
SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database
[src]
§
Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any
[src]

§Constructors

§
new SupabaseClient(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>)
[src]

Create a new client for use in the browser.

@param supabaseUrl

The unique Supabase URL which is supplied when you create a new project in your project dashboard.

@param supabaseKey

The unique Supabase Key which is supplied when you create a new project in your project dashboard.

@param options.db.schema

You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.

@param options.auth.autoRefreshToken

Set to "true" if you want to automatically refresh the token before expiring.

@param options.auth.persistSession

Set to "true" if you want to automatically save the user session into local storage.

@param options.auth.detectSessionInUrl

Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.

@param options.realtime

Options passed along to realtime-js constructor.

@param options.global.fetch

A custom fetch implementation.

@param options.global.headers

Any additional headers to send with each network request.

§Properties

§
_getAccessToken
[src]
§
_handleTokenChanged
[src]
§
_initRealtimeClient
[src]
§
_initSupabaseAuthClient
[src]
§
_listenForAuthEvents
[src]
§
authUrl: string
[src]
§
changedAccessToken: string
[src]
§
functionsUrl: string
[src]
§
headers: Record<string, string>
[src]
§
realtimeUrl: string
[src]
§
rest: PostgrestClient<Database, SchemaName>
[src]
§
storageKey: string
[src]
§
storageUrl: string
[src]
§
supabaseKey: string
[src]
§
supabaseUrl: string
[src]
§
auth: SupabaseAuthClient
[src]

Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies.

§
functions: FunctionsClient readonly
[src]

Supabase Functions allows you to deploy and invoke edge functions.

§
storage: SupabaseStorageClient readonly
[src]

Supabase Storage allows you to manage user-generated content, such as photos or videos.

§Methods

§
channel(name: string, opts?: RealtimeChannelOptions): RealtimeChannel
[src]

Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.

@param name
  • The name of the Realtime channel.
@param opts
  • The options to pass to the Realtime channel.
§
from<TableName extends string & keyof Schema["Tables"], Table extends Schema["Tables"][TableName]>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>
[src]
from<ViewName extends string & keyof Schema["Views"], View extends Schema["Views"][ViewName]>(relation: ViewName): PostgrestQueryBuilder<Schema, View, ViewName>
[src]
§
getChannels(): RealtimeChannel[]
[src]

Returns all Realtime channels.

§
removeAllChannels(): Promise<("ok" | "timed out" | "error")[]>
[src]

Unsubscribes and removes all Realtime channels from Realtime client.

§
removeChannel(channel: RealtimeChannel): Promise<"ok" | "timed out" | "error">
[src]

Unsubscribes and removes Realtime channel from Realtime client.

@param channel
  • The name of the Realtime channel.
§
rpc<FnName extends string & keyof Schema["Functions"], Fn extends Schema["Functions"][FnName]>(fn: FnName, args?: Fn["Args"], options?: {
head?: boolean;
count?: "exact" | "planned" | "estimated";
}
): PostgrestFilterBuilder<Schema, Fn["Returns"] extends any[] ? Fn["Returns"][number] extends Record<string, unknown> ? Fn["Returns"][number] : never : never, Fn["Returns"]>
[src]

Perform a function call.

@param fn
  • The function name to call
@param args
  • The arguments to pass to the function call
@param options
  • Named parameters
@param options.head
  • When set to true, data will not be returned. Useful if you only need the count.
@param options.count

"exact": Exact but slow count algorithm. Performs a COUNT(*) under the hood.

"planned": Approximated but fast count algorithm. Uses the Postgres statistics under the hood.

"estimated": Uses exact count for low numbers and planned count for high numbers.

§
schema<DynamicSchema extends string & keyof Database>(schema: DynamicSchema): PostgrestClient<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>
[src]

Select a schema to query or perform an function (rpc) call.

The schema needs to be on the list of exposed schemas inside Supabase.

@param schema
  • The schema to query