Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SupabaseClient<Database, SchemaName, Schema>

Supabase Client.

An isomorphic Javascript client for interacting with Postgres.

Type Parameters

  • 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

Hierarchy

  • SupabaseClient

Index

Constructors

  • new SupabaseClient<Database, SchemaName, Schema>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>): SupabaseClient<Database, SchemaName, Schema>
  • Create a new client for use in the browser.

    Type Parameters

    • Database = any

    • SchemaName extends string = "public" extends keyof Database ? "public" : string & keyof Database

    • Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? any[any] : any

    Parameters

    • supabaseUrl: string

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

    • supabaseKey: string

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

    • Optional options: SupabaseClientOptions<SchemaName>

    Returns SupabaseClient<Database, SchemaName, Schema>

Properties

accessToken?: (() => Promise<string>)

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

auth: SupabaseAuthClient

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

authUrl: string
changedAccessToken?: string
fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

Type declaration

    • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
    • Parameters

      • input: RequestInfo | URL
      • Optional init: RequestInit

      Returns Promise<Response>

functionsUrl: string
headers: Record<string, string>
realtime: RealtimeClient
realtimeUrl: string
rest: default<Database, SchemaName, Database[SchemaName] extends GenericSchema ? any[any] : any>
storageKey: string
storageUrl: string
supabaseKey: string
supabaseUrl: string

Accessors

  • get functions(): FunctionsClient
  • Supabase Functions allows you to deploy and invoke edge functions.

    Returns FunctionsClient

  • get storage(): StorageClient
  • Supabase Storage allows you to manage user-generated content, such as photos or videos.

    Returns StorageClient

Methods

  • _getAccessToken(): Promise<null | string>
  • _handleTokenChanged(event: AuthChangeEvent, source: "CLIENT" | "STORAGE", token?: string): void
  • _initSupabaseAuthClient(__namedParameters: SupabaseAuthClientOptions, headers?: Record<string, string>, fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)): SupabaseAuthClient
  • Parameters

    • __namedParameters: SupabaseAuthClientOptions
    • Optional headers: Record<string, string>
    • Optional fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)
        • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optional init: RequestInit

          Returns Promise<Response>

    Returns SupabaseAuthClient

  • _listenForAuthEvents(): { data: { subscription: Subscription } }
  • from<TableName, Table>(relation: TableName): default<Schema, Table, TableName, Table extends { Relationships: R } ? R : unknown>
  • from<ViewName, View>(relation: ViewName): default<Schema, View, ViewName, View extends { Relationships: R } ? R : unknown>
  • Perform a query on a table or a view.

    Type Parameters

    Parameters

    • relation: TableName

      The table or view name to query

    Returns default<Schema, Table, TableName, Table extends { Relationships: R } ? R : unknown>

  • Perform a query on a table or a view.

    Type Parameters

    Parameters

    • relation: ViewName

      The table or view name to query

    Returns default<Schema, View, ViewName, View extends { Relationships: R } ? R : unknown>

  • removeAllChannels(): Promise<("error" | "ok" | "timed out")[]>
  • Unsubscribes and removes all Realtime channels from Realtime client.

    Returns Promise<("error" | "ok" | "timed out")[]>

  • removeChannel(channel: RealtimeChannel): Promise<"error" | "ok" | "timed out">
  • Unsubscribes and removes Realtime channel from Realtime client.

    Parameters

    Returns Promise<"error" | "ok" | "timed out">

  • rpc<FnName, Fn>(fn: FnName, args?: Fn["Args"], options?: { count?: "exact" | "planned" | "estimated"; get?: boolean; head?: boolean }): default<Schema, Fn["Returns"] extends any[] ? any[any][number] extends Record<string, unknown> ? any[any] : never : never, Fn["Returns"], unknown, unknown>
  • Perform a function call.

    Type Parameters

    Parameters

    • fn: FnName

      The function name to call

    • args: Fn["Args"] = {}

      The arguments to pass to the function call

    • options: { count?: "exact" | "planned" | "estimated"; get?: boolean; head?: boolean } = {}

      Named parameters

      • Optional count?: "exact" | "planned" | "estimated"

        Count algorithm to use to count rows returned by the function. Only applicable for set-returning functions.

        "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.

      • Optional get?: boolean

        When set to true, the function will be called with read-only access mode.

      • Optional head?: boolean

        When set to true, data will not be returned. Useful if you only need the count.

    Returns default<Schema, Fn["Returns"] extends any[] ? any[any][number] extends Record<string, unknown> ? any[any] : never : never, Fn["Returns"], unknown, unknown>

  • schema<DynamicSchema>(schema: DynamicSchema): default<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? any[any] : any>
  • Select a schema to query or perform an function (rpc) call.

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

    Type Parameters

    • DynamicSchema extends string

    Parameters

    • schema: DynamicSchema

      The schema to query

    Returns default<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? any[any] : any>

Generated using TypeDoc