Skip to main content

Built and signed on GitHub Actions

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
2 days ago (2.50.2)
class SupabaseClient

Supabase Client.

An isomorphic Javascript client for interacting with Postgres.

Constructors

new
SupabaseClient(
supabaseUrl: string,
supabaseKey: string,
)

Create a new client for use in the browser.

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

Properties

protected
abstract
accessToken: () => Promise<string | null>
auth: SupabaseAuthClient

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

protected
authUrl: URL
protected
abstract
changedAccessToken: string
protected
abstract
fetch: Fetch
readonly
functions: FunctionsClient

Supabase Functions allows you to deploy and invoke edge functions.

protected
functionsUrl: URL
protected
headers: Record<string, string>
realtime: RealtimeClient
protected
realtimeUrl: URL
protected
rest: PostgrestClient<Database, SchemaName, Schema>
readonly
storage: SupabaseStorageClient

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

protected
storageKey: string
protected
storageUrl: URL

Methods

private
_handleTokenChanged(
event: AuthChangeEvent,
source: "CLIENT" | "STORAGE",
token?: string,
): void
private
_initRealtimeClient(options: RealtimeClientOptions)
private
_initSupabaseAuthClient(
unnamed 0: SupabaseAuthClientOptions,
headers?: Record<string, string>,
fetch?: Fetch,
)
channel(
name: string,
opts?: RealtimeChannelOptions,
): RealtimeChannel

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

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[]

Returns all Realtime channels.

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

Unsubscribes and removes all Realtime channels from Realtime client.

removeChannel(channel: RealtimeChannel): Promise<
"ok"
| "timed out"
| "error"
>

Unsubscribes and removes Realtime channel from Realtime client.

rpc<
FnName extends string & keyof Schema["Functions"],
Fn extends Schema["Functions"][FnName],
>
(
fn: FnName,
args?: Fn["Args"],
options?: { head?: boolean; get?: 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"], FnName, null>

Perform a function call.

schema<DynamicSchema extends string & keyof Database>(schema: DynamicSchema): PostgrestClient<Database, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : 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.

Add Package

deno add jsr:@supabase/supabase-js

Import symbol

import SupabaseClient from "@supabase/supabase-js";
or

Import directly with a jsr specifier

import SupabaseClient from "jsr:@supabase/supabase-js";

Add Package

pnpm i jsr:@supabase/supabase-js
or (using pnpm 10.8 or older)
pnpm dlx jsr add @supabase/supabase-js

Import symbol

import SupabaseClient from "@supabase/supabase-js";

Add Package

yarn add jsr:@supabase/supabase-js
or (using Yarn 4.8 or older)
yarn dlx jsr add @supabase/supabase-js

Import symbol

import SupabaseClient from "@supabase/supabase-js";

Add Package

vlt install jsr:@supabase/supabase-js

Import symbol

import SupabaseClient from "@supabase/supabase-js";

Add Package

npx jsr add @supabase/supabase-js

Import symbol

import SupabaseClient from "@supabase/supabase-js";

Add Package

bunx jsr add @supabase/supabase-js

Import symbol

import SupabaseClient from "@supabase/supabase-js";