包详细信息

@supabase/supabase-js

supabase26.4mMIT2.87.1

Isomorphic Javascript SDK for Supabase

javascript, typescript, supabase

自述文件


<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/supabase/supabase/master/packages/common/assets/images/supabase-logo-wordmark--dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/supabase/supabase/master/packages/common/assets/images/supabase-logo-wordmark--light.svg"> Supabase Logo </picture>

Supabase JS SDK

Isomorphic JavaScript SDK for Supabase - combining Auth, Database, Storage, Functions, and Realtime.

Guides · Reference Docs · TypeDoc

Build Package License: MIT pkg.pr.new

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:

<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>

or even:

<script src="https://unpkg.com/@supabase/supabase-js@2"></script>

Then you can use it from a global supabase variable:

<script>
  const { createClient } = supabase
  const _supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')

  console.log('Supabase Instance: ', _supabase)
  // ...
</script>

ESM

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

<script type="module">
  import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm'
  const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')

  console.log('Supabase Instance: ', supabase)
  // ...
</script>

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),
  },
})

Support Policy

This section outlines the scope of support for various runtime environments in Supabase JavaScript client.

Node.js

We only support Node.js versions that are in Active LTS or Maintenance status as defined by the official Node.js release schedule. This means we support versions that are currently receiving long-term support and critical bug fixes.

When a Node.js version reaches end-of-life and is no longer in Active LTS or Maintenance status, Supabase will drop it in a minor release, and this won't be considered a breaking change.

⚠️ Node.js 18 Deprecation Notice

Node.js 18 reached end-of-life on April 30, 2025. As announced in our deprecation notice, support for Node.js 18 was dropped in version 2.79.0.

If you must use Node.js 18, please use version 2.78.0, which is the last version that supported Node.js 18.

Deno

We support Deno versions that are currently receiving active development and security updates. We follow the official Deno release schedule and only support versions from the stable and lts release channels.

When a Deno version reaches end-of-life and is no longer receiving security updates, Supabase will drop it in a minor release, and this won't be considered a breaking change.

Browsers

All modern browsers are supported. We support browsers that provide native fetch API. For Realtime features, browsers must also support native WebSocket API.

Bun

We support Bun runtime environments. Bun provides native fetch support and is compatible with Node.js APIs. Since Bun does not follow a structured release schedule like Node.js or Deno, we support current stable versions of Bun and may drop support for older versions in minor releases without considering it a breaking change.

React Native

We support React Native environments with fetch polyfills provided by the framework. Since React Native does not follow a structured release schedule, we support current stable versions and may drop support for older versions in minor releases without considering it a breaking change.

Cloudflare Workers

We support Cloudflare Workers runtime environments. Cloudflare Workers provides native fetch support. Since Cloudflare Workers does not follow a structured release schedule, we support current stable versions and may drop support for older versions in minor releases without considering it a breaking change.

Important Notes

  • Experimental features: Features marked as experimental may be removed or changed without notice

Contributing

We welcome contributions! Please see our Contributing Guide for details on how to get started.

For major changes or if you're unsure about something, please open an issue first to discuss your proposed changes.

Building

# From the monorepo root
npx nx build supabase-js

# Or with watch mode for development
npx nx build supabase-js --watch

Testing

There's a complete guide on how to set up your environment for running locally the supabase-js integration tests. Please refer to TESTING.md.

Badges

Coverage Status

更新日志

2.87.0 (2025-12-08)

🚀 Features

  • storage: align analytics from method with { data, error } pattern (#1927)

🩹 Fixes

  • repo: update lock file after dependabot to use npm 11 (#1926)

❤️ Thank You

  • Katerina Skroumpelou @mandarini

2.86.2 (2025-12-04)

🩹 Fixes

  • storage: correct QueryVectorsResponse to use vectors instead of matches (#1922)

❤️ Thank You

  • Katerina Skroumpelou @mandarini

2.86.1 (2025-12-04)

🩹 Fixes

  • auth: suppress getsession warning when getuser is called first (#1898)
  • auth: code verifier remains in storage during edge cases (#1759)
  • postgrest: cross-schema rpc setof type inference (#1900)
  • repo: update lock file (#1910)
  • repo: lock file issues (#1919)
  • repo: update npm and install again (#1920)
  • supabase: add esm wrapper to resolve module not found error in nuxt (#1914)

❤️ Thank You

  • Katerina Skroumpelou @mandarini
  • Vaibhav @7ttp

2.86.0 (2025-11-26)

🚀 Features

  • storage: install iceberg-js and add from method (#1881)

❤️ Thank You

  • Katerina Skroumpelou @mandarini

2.85.0 (2025-11-26)

🚀 Features

  • realtime: add metadata to realtime user broadcast push (#1894)

🩹 Fixes

  • auth: oauth minor fixes on types (#1891)

❤️ Thank You

  • Cemal Kılıç @cemalkilic
  • Eduardo Gurgel

2.84.0 (2025-11-20)

🚀 Features

  • postgrest: add isdistinct and regex pattern matching operators (#1875)

🩹 Fixes

  • postgrest: validate empty or invalid relation names in Postgrest… (#1863)
  • realtime: simplify serializer by removing unnecessary types of messages (#1871)

❤️ Thank You

  • Eduardo Gurgel
  • Katerina Skroumpelou @mandarini
  • Soufiane Radouane @sofmega

2.83.0 (2025-11-18)

🚀 Features

  • storage: rename StorageAnalyticsApi to StorageAnalyticsClient (#1869)

❤️ Thank You

  • Katerina Skroumpelou @mandarini

2.82.0 (2025-11-18)

🚀 Features

  • auth: add OAuth grant listing and revocation endpoints (#1833)

🩹 Fixes

  • postgrest: bubble up fetch error causes and codes (#1856)
  • realtime: account for null refs when encoding messages (#1862)
  • storage: analytics bucket prop (#1852)

❤️ Thank You

  • Cemal Kılıç @cemalkilic
  • Eduardo Gurgel
  • Fabrizio @fenos
  • Katerina Skroumpelou @mandarini

2.81.1 (2025-11-11)

🩹 Fixes

  • auth: use Symbols for callback IDs to resolve Next.js 16 compatibility (#1847)
  • auth: add automatic browser redirect to signInWithSSO (#1849)
  • realtime: setAuth not required on custom jwt token (#1826)

❤️ Thank You

  • Filipe Cabaço @filipecabaco
  • Katerina Skroumpelou @mandarini

2.81.0 (2025-11-10)

🚀 Features

  • realtime: implement V2 serializer (#1829)

🩹 Fixes

  • auth: make webauthn param optional and move register params to webauthn (#1765)
  • auth: add providers type to UserAppMetadata interface (#1760)
  • auth: use direct attestation for registration/authentication (#1764)
  • functions: add configurable timeout and normalize abort/timeout errors as FunctionsFetchError (#1837)
  • realtime: ensure WebSocket connections are properly closed in teardown (#1841)

❤️ Thank You

  • Eduardo Gurgel
  • Katerina Skroumpelou @mandarini
  • Tanmay Sharma @tanmaysharma2001

2.80.0 (2025-11-06)

🚀 Features

  • auth: add TypeScript types for documented JWT claims fields (#1802)

🩹 Fixes

  • auth: only warn if multiple clients share a storage-key (#1767)

❤️ Thank You

  • Steve Hall @sh41
  • Sumit Kumar @Software-Engineering-Project-Team-Bob

2.79.0 (2025-11-04)

🚀 Features

  • auth: support throwing errors instead of returning them (#1766)
  • repo: remove node-fetch dependency, require Node.js 20+ (#1830)

❤️ Thank You

  • Katerina Skroumpelou @mandarini

2.78.0 (2025-10-30)

🚀 Features

  • auth: add OAuth 2.1 authorization consent management API calls (#1793)
  • auth: add OAuth client update support (#1812)
  • auth: refactor getAuthenticatorAssuranceLevel method (#1822)

🩹 Fixes

  • auth: remove redirection in getAuthorizationDetails (#1811)
  • auth: move session warning proxy from session to user object (#1817)

❤️ Thank You

  • Cemal Kılıç @cemalkilic
  • Katerina Skroumpelou @mandarini
  • Stojan Dimitrovski @hf

2.77.0 (2025-10-29)

🚀 Features

  • auth: add OAuth 2.1 authorization consent management API calls (#1793)
  • auth: add OAuth client update support (#1812)
  • storage: add support for bucket pagination and sorting (#1790)

🩹 Fixes

  • auth: handle 204 No Content response in OAuth client delete (#1786)
  • auth: remove redirection in getAuthorizationDetails (#1811)
  • postgrest: add incoming major 14 support (#1807)
  • repo: add missing tslib dependency to core packages (#1789)
  • repo: cleanup package-lock.json and bun.lock (#1799)
  • storage: remove unnecessary filter (#1809)

🔥 Performance

  • precompile RegExp (#1806)

❤️ Thank You

  • Andrew Valleteau @avallete
  • Cemal Kılıç @cemalkilic
  • Fabrizio @fenos
  • Katerina Skroumpelou @mandarini
  • Kevin Grüneberg @kevcodez
  • Lenny @itslenny

2.76.1 (2025-10-21)

🩹 Fixes

  • repo: add missing tslib dependency to core packages (#1789)

❤️ Thank You

  • Katerina Skroumpelou @mandarini

2.76.0 (2025-10-20)

🚀 Features

  • realtime: realtime explicit REST call (#1751)
  • realtime: enhance RealtimeChannel type (#1747)
  • storage: storage vectors and analytics in storage-js (#1752)

🩹 Fixes

  • functions: missing body when Content-Type header supplied by dev (#1758)
  • functions: add application/pdf response parsing to FunctionsClient (#1757)
  • realtime: manipulate URLs using URL object (#1769)
  • repo: convert postbuild to explicit codegen (#1778)
  • storage: correct list v2 types to correctly match data returned from api (#1761)
  • storage: use backward compatible return type in download function (#1750)
  • storage: api types (#1784)

❤️ Thank You

  • Fabrizio @fenos
  • Filipe Cabaço @filipecabaco
  • Guilherme Souza
  • Katerina Skroumpelou @mandarini
  • Lenny @itslenny

2.75.1 (2025-10-17)

🩹 Fixes

  • storage: use backward compatible return type in download function (#1750)

❤️ Thank You

  • Lenny @itslenny

2.75.0 (2025-10-09)

🚀 Features

  • postgrest: add embeded functions type inference (#1632)

❤️ Thank You

  • Andrew Valleteau @avallete

2.74.0 (2025-10-07)

🚀 Features

  • auth: add deprecation notice to onAuthStateChange with async function (#1580)
  • auth: add OAuth 2.1 client admin endpoints (#1582)
  • docs: explicitly mark options as optional (#1622)
  • realtime: add support to configure Broadcast Replay (#1623)
  • release: enable trusted publishing (#1592)
  • storage: add support for sorting to list v2 (#1606)

🩹 Fixes

  • storage: remove trailing slash from baseUrl normalization (#1589)

❤️ Thank You

  • Cemal Kılıç @cemalkilic
  • Doğukan Akkaya
  • Eduardo Gurgel
  • Etienne Stalmans @staaldraad
  • Lenny @itslenny
  • Stojan Dimitrovski @hf
  • Taketo Yoshida