The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
generate the initializing client page
Inian704e54f1c03b
diff --git a/apps/reference/_supabase_js/generated/initializing.mdx b/apps/reference/_supabase_js/generated/initializing.mdxnew file mode 100644index 00000000000..5946c73dd83--- /dev/null+++ b/apps/reference/_supabase_js/generated/initializing.mdx@@ -0,0 +1,431 @@+---+id: initializing+title: 'Initializing'+slug: /initializing+custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml+---++import Tabs from '@theme/Tabs'+import TabItem from '@theme/TabItem'++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.++## Parameters++<ul className="method-list-group">++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ supabaseUrl+ </span>+ <span className="method-list-item-label-badge required">+ required+ </span>+ <span className="method-list-item-validation">+ <code>string</code>+ </span>+ </h4>+ <div class="method-list-item-description">++The unique Supabase URL which is supplied when you create a new project in your project dashboard.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ supabaseKey+ </span>+ <span className="method-list-item-label-badge required">+ required+ </span>+ <span className="method-list-item-validation">+ <code>string</code>+ </span>+ </h4>+ <div class="method-list-item-description">++The unique Supabase Key which is supplied when you create a new project in your project dashboard.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ SupabaseClientOptions+ </span>+ <span className="method-list-item-label-badge required">+ required+ </span>+ <span className="method-list-item-validation">+ <code>object</code>+ </span>+ </h4>+ <div class="method-list-item-description">++No description provided.++ </div>++<ul className="method-list-group">+ <h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ auth+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>object</code>+ </span>+ </h4>+ <div class="method-list-item-description">++No description provided.++ </div>++<ul className="method-list-group">+ <h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ autoRefreshToken+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>boolean</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Automatically refreshes the token for logged in users.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ cookieOptions+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>object</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Options passed to the gotrue-js instance++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ detectSessionInUrl+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>boolean</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Detect a session from the URL. Used for OAuth login callbacks.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ persistSession+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>boolean</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Whether to persist a logged in session to storage.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ storage+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>object</code>+ </span>+ </h4>+ <div class="method-list-item-description">++A storage provider. Used to store the logged in session.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ storageKey+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>string</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Optional key name used for storing tokens in local storage++ </div>++</li>++</ul>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ db+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>object</code>+ </span>+ </h4>+ <div class="method-list-item-description">++The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to 'public'.++ </div>++<ul className="method-list-group">+ <h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ schema+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>SchemaName</code>+ </span>+ </h4>+ <div class="method-list-item-description">++No description provided.++ </div>++</li>++</ul>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ global+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>object</code>+ </span>+ </h4>+ <div class="method-list-item-description">++No description provided.++ </div>++<ul className="method-list-group">+ <h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ fetch+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>Fetch</code>+ </span>+ </h4>+ <div class="method-list-item-description">++A custom `fetch` implementation.++ </div>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ headers+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>Record</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Optional headers for initializing the client.++ </div>++</li>++</ul>++</li>++<li className="method-list-item">+ <h4 className="method-list-item-label">+ <span className="method-list-item-label-name">+ realtime+ </span>+ <span className="method-list-item-label-badge false">+ optional+ </span>+ <span className="method-list-item-validation">+ <code>RealtimeClientOptions</code>+ </span>+ </h4>+ <div class="method-list-item-description">++Options passed to the realtime-js instance++ </div>++</li>++</ul>++</li>++</ul>++## Examples++### createClient()++```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'+)+```++### With additional parameters++```js+import { createClient } from '@supabase/supabase-js'++const options = {+ schema: 'public',+ headers: { 'x-my-custom-header': 'my-app-name' },+ autoRefreshToken: true,+ persistSession: true,+ detectSessionInUrl: true,+}+const supabase = createClient(+ 'https://xyzcompany.supabase.co',+ 'public-anon-key',+ options+)+```++### API schemas++```js+import { createClient } from '@supabase/supabase-js'++// Provide a custom schema. Defaults to "public".+const supabase = createClient(+ 'https://xyzcompany.supabase.co',+ 'public-anon-key',+ {+ 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.++### Custom `fetch` implementation++```js+import { createClient } from '@supabase/supabase-js'++const supabase = createClient(+ 'https://xyzcompany.supabase.co',+ 'public-anon-key',+ {+ 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).diff --git a/apps/reference/_supabase_js/generated/subscribe.mdx b/apps/reference/_supabase_js/generated/subscribe.mdxindex 346bd7632c7..6b88cc3c709 100644--- a/apps/reference/_supabase_js/generated/subscribe.mdx+++ b/apps/reference/_supabase_js/generated/subscribe.mdx@@ -217,3 +217,16 @@ const myChannel = supabase).subscribe()```++### Listening to Broadcast changes++You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.++```js+const myChannel = supabase+ .channel('broadcastChannel', {+ configs: { broadcast: { self: true, ack: true } },+ })+ .on('broadcast', { event: 'post' }, (payload) => console.log(payload))+ .subscribe()+```diff --git a/apps/reference/_supabase_js/initializing.mdx b/apps/reference/_supabase_js/initializing.mdxdeleted file mode 100644index f921020d8f0..00000000000--- a/apps/reference/_supabase_js/initializing.mdx+++ /dev/null@@ -1,195 +0,0 @@-----id: initializing-title: 'Initializing'-slug: initializing-custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml------import Tabs from '@theme/Tabs'-import TabItem from '@theme/TabItem'--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.--## Parameters--<ul className="method-list-group">--<li className="method-list-item">- <h4 className="method-list-item-label">- <span className="method-list-item-label-name">- supabaseUrl- </span>- <span className="method-list-item-label-badge required">- required- </span>- <span className="method-list-item-validation">- <code>string</code>- </span>- </h4>- <div class="method-list-item-description">--The unique Supabase URL which is supplied when you create a new project in your project dashboard.-- </div>--</li>--<li className="method-list-item">- <h4 className="method-list-item-label">- <span className="method-list-item-label-name">- supabaseKey- </span>- <span className="method-list-item-label-badge required">- required- </span>- <span className="method-list-item-validation">- <code>string</code>- </span>- </h4>- <div class="method-list-item-description">--The unique Supabase Key which is supplied when you create a new project in your project dashboard.-- </div>--</li>--<li className="method-list-item">- <h4 className="method-list-item-label">- <span className="method-list-item-label-name">- options- </span>- <span className="method-list-item-label-badge false">- optional- </span>- <span className="method-list-item-validation">- <code>SupabaseClientOptions</code>- </span>- </h4>- <div class="method-list-item-description">--No description provided.-- </div>--</li>--</ul>--## Examples--### createClient()--<Tabs- defaultValue="js"- groupId="reference/supabase-js"- values={[{ label: 'JavaScript', value: 'js' }]}>--<TabItem value="js">--```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'-)-```--</TabItem>--</Tabs>--### With additional parameters--<Tabs- defaultValue="js"- groupId="reference/supabase-js"- values={[{ label: 'JavaScript', value: 'js' }]}>--<TabItem value="js">--```js-import { createClient } from '@supabase/supabase-js'--const options = {- schema: 'public',- headers: { 'x-my-custom-header': 'my-app-name' },- autoRefreshToken: true,- persistSession: true,- detectSessionInUrl: true,-}-const supabase = createClient(- 'https://xyzcompany.supabase.co',- 'public-anon-key',- options-)-```--</TabItem>--</Tabs>--### API schemas--<Tabs- defaultValue="js"- groupId="reference/supabase-js"- values={[{ label: 'JavaScript', value: 'js' }]}>--<TabItem value="js">--```js-import { createClient } from '@supabase/supabase-js'--// Provide a custom schema. Defaults to "public".-const supabase = createClient(- 'https://xyzcompany.supabase.co',- 'public-anon-key',- {- 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.--</TabItem>--</Tabs>--### Custom `fetch` implementation--<Tabs- defaultValue="js"- groupId="reference/supabase-js"- values={[{ label: 'JavaScript', value: 'js' }]}>--<TabItem value="js">--```js-import { createClient } from '@supabase/supabase-js'--const supabase = createClient(- 'https://xyzcompany.supabase.co',- 'public-anon-key',- {- 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).--</TabItem>--</Tabs>diff --git a/apps/reference/nav/supabase_js_sidebars.js b/apps/reference/nav/supabase_js_sidebars.jsindex 542c673ad7f..4ea62fe817e 100644--- a/apps/reference/nav/supabase_js_sidebars.js+++ b/apps/reference/nav/supabase_js_sidebars.js@@ -23,7 +23,7 @@ const sidebars = {items: ['intro','installing',- 'initializing',+ 'generated/initializing','typescript-support','release-notes',],diff --git a/spec/supabase_js_v2_legacy.yml b/spec/supabase_js_v2_legacy.ymlindex db56e065b33..cc7caa5b75f 100644--- a/spec/supabase_js_v2_legacy.yml+++ b/spec/supabase_js_v2_legacy.yml@@ -16,6 +16,65 @@ info:version: '0.0.1'pages:+ 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:+ - name: createClient()+ js: |+ ```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')+ ```+ - name: With additional parameters+ js: |+ ```js+ import { createClient } from '@supabase/supabase-js'++ const options = {+ schema: 'public',+ headers: { 'x-my-custom-header': 'my-app-name' },+ autoRefreshToken: true,+ persistSession: true,+ detectSessionInUrl: true+ }+ const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", options)+ ```+ - name: API schemas+ js: |+ ```js+ import { createClient } from '@supabase/supabase-js'++ // Provide a custom schema. Defaults to "public".+ const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {+ 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.+ - name: Custom `fetch` implementation+ js: |+ ```js+ import { createClient } from '@supabase/supabase-js'++ const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {+ 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).auth.signUp():title: 'signUp()'$ref: '@supabase/gotrue-js.GoTrueClient.signUp'@@ -47,8 +106,8 @@ pages:email: '[email protected]',password: 'example-password',options: {- data: {- first_name: 'John',+ data: {+ first_name: 'John',age: 27,}}@@ -94,9 +153,9 @@ pages:$ref: '@supabase/gotrue-js.GoTrueClient.signInWithOtp'notes: |- This method is used for passwordless sign-ins where an otp is sent to the user's email or phone number.- - Requires either an email or phone number.- - If you're using an email, you can configure whether you want the user to receive a magiclink or an otp.- - If you're using phone, you can configure whether you want the user to receive a magiclink or an otp.+ - Requires either an email or phone number.+ - If you're using an email, you can configure whether you want the user to receive a magiclink or an otp.+ - If you're using phone, you can configure whether you want the user to receive a magiclink or an otp.- The magic link's destination URL is determined by the SITE_URL config variable. To change this, you can go to Authentication -> Settings on [app.supabase.com](https://app.supabase.com)examples:- name: Sign in with email.@@ -136,7 +195,7 @@ pages:isSpotlight: falsedescription: |The `redirectTo` param will only applied on the callback made from the third-party provider. It does not redirect the user immediately after invoking this method.- In order for the `redirectTo` param to be allowed, one needs to include it in an allowlist. Supabase supports this for+ In order for the `redirectTo` param to be allowed, one needs to include it in an allowlist. Supabase supports this forany URL path on your website (the URL must either be on the same domain as your Site URL [see Auth>Settings in dashboard], or must match one of the Additional Redirect URLs [also in Auth>Settings]).js: |```js