GitHub - supabase/supabase-js: 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. (original) (raw)

supabase-js - Isomorphic JavaScript Client for Supabase.

Note

Do you want to help us shape the future of this library? We're hiring.

Usage

First of all, you need to install the library:

npm install @supabase/supabase-js

Then you're able to import the library and establish the connection with the database:

import { createClient } from '@supabase/supabase-js'

// Create a single supabase client for interacting with your database const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')

UMD

You can use plain <script>s to import supabase-js from CDNs, like:

or even:

Then you can use it from a global supabase variable:

ESM

You can use <script type="module"> to import supabase-js from CDNs, like:

Deno

You can use supabase-js in the Deno runtime via JSR:

import { createClient } from 'jsr:@supabase/supabase-js@2'

Custom fetch implementation

supabase-js uses the cross-fetch library to make HTTP requests, but an alternative fetch implementation can be provided as an option. This is most useful in environments where cross-fetch is not compatible, for instance Cloudflare Workers:

import { createClient } from '@supabase/supabase-js'

// Provide a custom fetch implementation as an option const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', { global: { fetch: (...args) => fetch(...args), }, })

Badges

Coverage Status