Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add reduced yaml file

Terry Sutton099971c5bd1c
diff --git a/spec/supabase_js_v2_temp_new_shape--reduced.yml b/spec/supabase_js_v2_temp_new_shape--reduced.yml
new file mode 100644
index 00000000000..2e5c827cd45
--- /dev/null
+++ b/spec/supabase_js_v2_temp_new_shape--reduced.yml
@@ -0,0 +1,301 @@
+openref: 0.1
+
+info:
+ id: reference/supabase-js
+ title: Supabase Client
+ description: |
+
+ Supabase JavaScript.
+
+ definition: ../../spec/enrichments/tsdoc_v2/combined.json
+ specUrl: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2.yml
+ slugPrefix: '/'
+ libraries:
+ - id: 'JavaScript'
+ version: '0.0.1'
+
+functions:
+ - id: initializing
+ $ref: '@supabase/supabase-js.index.SupabaseClient.constructor'
+ description: |
+ You can initialize a new Supabase client using the `createClient()` method.
+
+ The Supabase client is your entrypoint to the rest of the Supabase functionality
+ and is the easiest way to interact with everything we offer within the Supabase ecosystem.
+
+ examples:
+ - id: create-client
+ name: createClient()
+ code: |
+ ```js
+ 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')
+ ```
+ - id: with-additional-parameters
+ name: With additional parameters
+ code: |
+ ```js
+ import { createClient } from '@supabase/supabase-js'
+
+ const options = {
+ db: {
+ schema: 'public',
+ },
+ auth: {
+ autoRefreshToken: true,
+ persistSession: true,
+ detectSessionInUrl: true
+ },
+ global: {
+ headers: { 'x-my-custom-header': 'my-app-name' },
+ },
+ }
+ const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", options)
+ ```
+ - id: api-schemas
+ name: API schemas
+ code: |
+ ```js
+ import { createClient } from '@supabase/supabase-js'
+
+ // Provide a custom schema. Defaults to "public".
+ const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
+ db: { schema: 'other_schema' }
+ })
+ ```
+
+ By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
+ Go to `Settings > API > Schema` and add the schema which you want to expose to the API.
+
+ Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.
+ - id: custom-fetch-implementation
+ name: Custom `fetch` implementation
+ code: |
+ ```js
+ import { createClient } from '@supabase/supabase-js'
+
+ const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
+ global: { fetch: fetch.bind(globalThis) }
+ })
+ ```
+
+ `supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/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).
+ - id: react-native-options
+ name: React Native options
+ code: |
+ ```js
+ import { createClient } from '@supabase/supabase-js'
+ import AsyncStorage from "@react-native-async-storage/async-storage";
+
+ const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", {
+ auth: {
+ storage: AsyncStorage,
+ autoRefreshToken: true,
+ persistSession: true,
+ detectSessionInUrl: false,
+ },
+ });
+ ```
+
+ For React Native we recommend using `AsyncStorage` as the storage implementation for Supabase Auth.
+ - id: auth.signUp()
+ title: 'signUp()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.signUp'
+ notes: |
+ - By default, the user needs to verify their email address before logging in. To turn this off, disable **Confirm email** in [your project](https://app.supabase.com/project/_/auth/settings).
+ - **Confirm email** determines if users need to confirm their email address after signing up.
+ - If **Confirm email** is enabled, a `user` is returned but `session` is null.
+ - If **Confirm email** is disabled, both a `user` and a `session` are returned.
+ - When the user confirms their email address, they are redirected to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](https://app.supabase.com/project/_/auth/settings).
+ - If signUp() is called for an existing confirmed user:
+ - If **Confirm email** is enabled in [your project](https://app.supabase.com/project/_/auth/settings), an obfuscated/fake user object is returned.
+ - If **Confirm email** is disabled, the error message, `User already registered` is returned.
+ - To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/javascript/auth-getuser).
+ examples:
+ - id: sign-up.
+ name: Sign up.
+ isSpotlight: true
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signUp({
+ email: '[email protected]',
+ password: 'example-password',
+ })
+ ```
+ - id: sign-up-with-additional-user-metadata.
+ name: Sign up with additional user metadata.
+ isSpotlight: false
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signUp(
+ {
+ email: '[email protected]',
+ password: 'example-password',
+ options: {
+ data: {
+ first_name: 'John',
+ age: 27,
+ }
+ }
+ }
+ )
+ ```
+ - id: auth.signInWithPassword()
+ title: 'signInWithPassword()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.signInWithPassword'
+ notes: |
+ - Requires either an email and password or a phone number and password.
+ examples:
+ - id: sign-in-with-email-and-password
+ name: Sign in with email and password
+ isSpotlight: true
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithPassword({
+ email: '[email protected]',
+ password: 'example-password',
+ })
+ ```
+ - id: sign-in-with-phone-and-password
+ name: Sign in with phone and password
+ isSpotlight: false
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithPassword({
+ phone: '+13334445555',
+ password: 'some-password',
+ })
+
+ // After receiving a SMS with a OTP.
+ const { data, error } = await supabase.auth.verifyOtp({
+ phone: '+13334445555',
+ token: '123456',
+ })
+ ```
+ - id: auth.signInWithOtp()
+ title: 'signInWithOtp()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.signInWithOtp'
+ notes: |
+ - Requires either an email or phone number.
+ - This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
+ - If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.
+ - If you're using phone, you can configure whether you want the user to receive a OTP.
+ - The magic link's destination URL is determined by the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
+ examples:
+ - id: sign-in-with-email.
+ name: Sign in with email.
+ isSpotlight: true
+ description: The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds.
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithOtp({
+ email: '[email protected]',
+ })
+ ```
+ - id: sign-in-with-sms-otp.
+ name: Sign in with SMS OTP.
+ isSpotlight: false
+ description: The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds.
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithOtp({
+ phone: '+13334445555',
+ })
+ ```
+ - id: auth.signInWithOAuth()
+ title: 'signInWithOAuth()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.signInWithOAuth'
+ notes: |
+ - This method is used for signing in using a third-party provider.
+ - Supabase supports many different [third-party providers](https://supabase.com/docs/guides/auth#providers).
+ examples:
+ - id: sign-in-using-a-third-party-provider
+ name: Sign in using a third-party provider
+
+ isSpotlight: true
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithOAuth({
+ provider: 'github'
+ })
+ ```
+ - id: sign-in-using-a-third-party-provider-with-redirect
+ name: Sign in using a third-party provider with redirect
+ isSpotlight: false
+ description: |
+ When the third-party provider successfully authenticates the user, the provider will redirect the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method.
+ You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithOAuth({
+ provider: 'github'
+ options: {
+ redirectTo: 'https://example.com/welcome'
+ }
+ }
+ ```
+ - id: sign-in-with-scopes
+ name: Sign in with scopes
+ isSpotlight: false
+ description: |
+ If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token.
+ You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider. The list of scopes will be documented by the third-party provider you are using and specifying scopes will enable you to use the OAuth provider token to call additional APIs supported by the third-party provider to get more information.
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithOAuth({
+ provider: 'github'
+ options: {
+ scopes: 'repo gist notifications'
+ }
+ })
+ const oAuthToken = data.session.provider_token // use to access provider API
+ ```
+ - id: auth.signOut()
+ title: 'signOut()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.signOut'
+ notes: |
+ - In order to use the `signOut()` method, the user needs to be signed in first.
+ examples:
+ - id: sign-out
+ name: Sign out
+ isSpotlight: true
+ code: |
+ ```js
+ const { error } = await supabase.auth.signOut()
+ ```
+ - id: auth.verifyOtp()
+ title: 'verifyOtp()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.verifyOtp'
+ notes: |
+ - The `verifyOtp` method takes in different verification types. If a phone number is used, the type can either be `sms` or `phone_change`. If an email address is used, the type can be one of the following: `signup`, `magiclink`, `recovery`, `invite` or `email_change`.
+ - The verification type used should be determined based on the corresponding auth method called before `verifyOtp` to sign up / sign-in a user.
+ examples:
+ - id: verify-sms-one-time-password(otp)
+ name: Verify Sms One-Time Password (OTP)
+ isSpotlight: true
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})
+ ```
+ - id: verify-signup-one-time-password(otp)
+ name: Verify Signup One-Time Password (OTP)
+ isSpotlight: false
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'signup'})
+ ```
+ - id: auth.getSession()
+ title: 'getSession()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.getSession'
+ examples:
+ - id: get-the-session-data
+ name: Get the session data
+ isSpotlight: true
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.getSession()
+ ```