The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: add type hints (#34678)
Charis258bc3791907
diff --git a/apps/docs/app/contributing/content.mdx b/apps/docs/app/contributing/content.mdxindex 2aa13816df6..221952b059b 100644--- a/apps/docs/app/contributing/content.mdx+++ b/apps/docs/app/contributing/content.mdx@@ -159,10 +159,10 @@ Additional helpful information.### Code Samples-You can include code samples as normal in Markdown:+You can include code samples as normal in Markdown. Name is optional:````mdx-```js+```js name=file.jsconst PI = 3.14```````@@ -232,8 +232,6 @@ console.log('Goodbye, world!')</$CodeTabs>-If you want to give a file name for your code sample, you can also use `<$CodeTabs>` with only one code block.-#### TypeScript type hintsJavaScript and TypeScript code blocks include type hints:diff --git a/apps/docs/components/ApiSchema.tsx b/apps/docs/components/ApiSchema.tsxindex 6a5ee1c11cf..952d60951f6 100644--- a/apps/docs/components/ApiSchema.tsx+++ b/apps/docs/components/ApiSchema.tsx@@ -1,5 +1,6 @@-import { CodeBlock } from '@ui/components/CodeBlock'import { sample } from '@har-sdk/openapi-sampler'++import { CodeBlock } from '~/features/ui/CodeBlock/CodeBlock'import { Tabs, TabPanel } from '~/features/ui/Tabs'type IParamProps = any@@ -21,17 +22,13 @@ const ApiSchema = ({ schema, id }: IParamProps) => {{example && (<TabPanel key={`${id ?? ''}-example`} id="example" label="example"><div className="mt-8">- <CodeBlock language="bash" className="relative">- {JSON.stringify(example, null, 2)}- </CodeBlock>+ <CodeBlock lang="bash">{JSON.stringify(example, null, 2)}</CodeBlock></div></TabPanel>)}<TabPanel key={`${id ?? ''}-schema`} id="schema" label="schema"><div className="mt-8">- <CodeBlock language="bash" className="relative">- {JSON.stringify(schema, null, 2)}- </CodeBlock>+ <CodeBlock lang="bash">{JSON.stringify(schema, null, 2)}</CodeBlock></div></TabPanel></Tabs>diff --git a/apps/docs/content/_partials/oauth_pkce_flow.mdx b/apps/docs/content/_partials/oauth_pkce_flow.mdxindex 707c0e276c1..a670367a1d7 100644--- a/apps/docs/content/_partials/oauth_pkce_flow.mdx+++ b/apps/docs/content/_partials/oauth_pkce_flow.mdx@@ -12,6 +12,11 @@ For a PKCE flow, for example in Server-Side Auth, you need an extra step to handIn the browser, `signInWithOAuth` automatically redirects to the OAuth provider's authentication endpoint, which then redirects to your endpoint.```js+import { createClient, type Provider } from '@supabase/supabase-js';+const supabase = createClient('url', 'anonKey')+const provider = 'provider' as Provider++// ---cut---await supabase.auth.signInWithOAuth({provider,options: {@@ -27,6 +32,12 @@ await supabase.auth.signInWithOAuth({In the server, you need to handle the redirect to the OAuth provider's authentication endpoint. The `signInWithOAuth` method returns the endpoint URL, which you can redirect to.```js+import { createClient, type Provider } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')+const provider = 'provider' as Provider+const redirect = (url: string) => {}++// ---cut---const { data, error } = await supabase.auth.signInWithOAuth({provider,options: {@@ -56,7 +67,7 @@ At the callback endpoint, handle the code exchange to save the user session.Create a new file at `app/auth/callback/route.ts` and populate with the following:-```ts app/auth/callback/route.ts+```ts name=app/auth/callback/route.tsimport { NextResponse } from 'next/server'// The client you created from the Server-Side Auth instructionsimport { createClient } from '@/utils/supabase/server'@@ -94,7 +105,7 @@ export async function GET(request: Request) {Create a new file at `src/routes/auth/callback/+server.js` and populate with the following:-```js src/routes/auth/callback/+server.js+```js name=src/routes/auth/callback/+server.jsimport { redirect } from '@sveltejs/kit';export const GET = async (event) => {@@ -123,7 +134,7 @@ export const GET = async (event) => {Create a new file at `src/pages/auth/callback.ts` and populate with the following:-```ts src/pages/auth/callback.ts+```ts name=src/pages/auth/callback.tsimport { createServerClient, parseCookieHeader } from '@supabase/ssr'import { type APIRoute } from 'astro'@@ -168,7 +179,7 @@ export const GET: APIRoute = async ({ request, cookies, redirect }) => {Create a new file at `app/routes/auth.callback.tsx` and populate with the following:-```ts app/routes/auth.callback.tsx+```ts name=app/routes/auth.callback.tsximport { redirect, type LoaderFunctionArgs } from '@remix-run/node'import { createServerClient, parseCookieHeader, serializeCookieHeader } from '@supabase/ssr'@@ -209,7 +220,7 @@ export async function loader({ request }: LoaderFunctionArgs) {Create a new route in your express app and populate with the following:-```js app.js+```js name=app.js...app.get("/auth/callback", async function (req, res) {const code = req.query.codediff --git a/apps/docs/content/guides/auth/auth-anonymous.mdx b/apps/docs/content/guides/auth/auth-anonymous.mdxindex 04433660137..b46189ad5de 100644--- a/apps/docs/content/guides/auth/auth-anonymous.mdx+++ b/apps/docs/content/guides/auth/auth-anonymous.mdx@@ -56,6 +56,10 @@ For self-hosting, you can update your project configuration using the files andCall the [`signInAnonymously()`](/docs/reference/javascript/auth-signinanonymously) method:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---const { data, error } = await supabase.auth.signInAnonymously()```@@ -116,13 +120,21 @@ Converting an anonymous user to a permanent user requires [linking an identity](You can use the [`updateUser()`](/docs/reference/javascript/auth-updateuser) method to link an email or phone identity to the anonymous user. To add a password for the anonymous user, the user's email or phone number needs to be verified first.```js-const { data, error } = await supabase.auth.updateUser({ email: '[email protected]' })+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---+const { data: updateEmailData, error: updateEmailError } = await supabase.auth.updateUser({+ email: '[email protected]',+})// verify the user's email by clicking on the email change link// or entering the 6-digit OTP sent to the email address// once the user has been verified, update the password-const { data, error } = await supabase.auth.updateUser({ password: 'password' })+const { data: updatePasswordData, error: updatePasswordError } = await supabase.auth.updateUser({+ password: 'password',+})```</TabPanel>@@ -192,6 +204,10 @@ response = supabase.auth.update_user({You can use the [`linkIdentity()`](/docs/reference/javascript/auth-linkidentity) method to link an OAuth identity to the anonymous user.```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---const { data, error } = await supabase.auth.linkIdentity({ provider: 'google' })```diff --git a/apps/docs/content/guides/auth/auth-email-passwordless.mdx b/apps/docs/content/guides/auth/auth-email-passwordless.mdxindex 8a906f248ac..5df8c8dbc81 100644--- a/apps/docs/content/guides/auth/auth-email-passwordless.mdx+++ b/apps/docs/content/guides/auth/auth-email-passwordless.mdx@@ -46,6 +46,10 @@ If the user hasn't signed up yet, they are automatically signed up by default. T<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---async function signInWithEmail() {const { data, error } = await supabase.auth.signInWithOtp({email: '[email protected]',@@ -141,7 +145,14 @@ If you're using PKCE flow, edit the Magic Link [email template](/docs/guides/autAt the `/auth/confirm` endpoint, exchange the hash for the session:```js-const { error } = await supabase.auth.verifyOtp({ token_hash, type })+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---+const { error } = await supabase.auth.verifyOtp({+ token_hash: 'hash',+ type: 'email',+})```## With OTP@@ -182,6 +193,10 @@ If the user hasn't signed up yet, they are automatically signed up by default. T<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---const { data, error } = await supabase.auth.signInWithOtp({email: '[email protected]',options: {@@ -266,11 +281,15 @@ Call the "verify OTP" method from your client library with the user's email addr<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---const {data: { session },error,} = await supabase.auth.verifyOtp({- email,+ email: '[email protected]',token: '123456',type: 'email',})diff --git a/apps/docs/content/guides/auth/auth-email-templates.mdx b/apps/docs/content/guides/auth/auth-email-templates.mdxindex 64abf43f500..af34bfd7f4c 100644--- a/apps/docs/content/guides/auth/auth-email-templates.mdx+++ b/apps/docs/content/guides/auth/auth-email-templates.mdx@@ -73,12 +73,16 @@ You can customize the email link in the email template to redirect the user to aWhen the user clicks on the link, the request will hit `https://api.example.com/v1/authenticate` and you can grab the `token_hash`, `type` and `redirect_to` query parameters from the URL. Then, you can call the [`verifyOtp`](/docs/reference/javascript/auth-verifyotp) method to get back an authenticated session before redirecting the user back to the client. Since the `verifyOtp` method makes a `POST` request to Supabase Auth to verify the user, the session will be returned in the response body, which can be read by the server. For example:-```js+```ts+import { createClient, type EmailOtpType } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---const { token_hash, type } = Object.fromEntries(new URLSearchParams(window.location.search))const {data: { session },error,-} = await supabase.auth.verifyOtp({ token_hash, type })+} = await supabase.auth.verifyOtp({ token_hash, type: type as EmailOtpType })// subsequently redirect the user back to the client using the redirect_to param// ...diff --git a/apps/docs/content/guides/auth/auth-identity-linking.mdx b/apps/docs/content/guides/auth/auth-identity-linking.mdxindex 36c6dffcfd3..43198263a2c 100644--- a/apps/docs/content/guides/auth/auth-identity-linking.mdx+++ b/apps/docs/content/guides/auth/auth-identity-linking.mdx@@ -34,6 +34,10 @@ Users that signed up with [SAML SSO](/docs/guides/auth/sso/auth-sso-saml) will nSupabase Auth allows a user to initiate identity linking with a different email address when they are logged in. To link an OAuth identity to the user, call [`linkIdentity()`](/docs/reference/javascript/auth-linkidentity):```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-supabase-url>', '<your-supabase-anon-key>')++// ---cut---const { data, error } = await supabase.auth.linkIdentity({ provider: 'google' })```@@ -92,16 +96,22 @@ In the example above, the user will be redirected to Google to complete the OAutYou can use [`getUserIdentities()`](/docs/reference/javascript/auth-getuseridentities) to fetch all the identities linked to a user. Then, call [`unlinkIdentity()`](/docs/reference/javascript/auth-unlinkidentity) to unlink the identity. The user needs to be logged in and have at least 2 linked identities in order to unlink an existing identity.```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-supabase-url>', '<your-supabase-anon-key>')++// ---cut---// retrieve all identities linked to a user-const {- data: { identities },-} = await supabase.auth.getUserIdentities()+const { data: identities, error: identitiesError } = await supabase.auth.getUserIdentities()-// find the google identity linked to the user-const googleIdentity = identities.find((identity) => identity.provider === 'google')+if (!identitiesError) {+ // find the google identity linked to the user+ const googleIdentity = identities.identities.find((identity) => identity.provider === 'google')-// unlink the google identity from the user-const { data, error } = await supabase.auth.unlinkIdentity(googleIdentity)+ if (googleIdentity) {+ // unlink the google identity from the user+ const { data, error } = await supabase.auth.unlinkIdentity(googleIdentity)+ }+}```</TabPanel>diff --git a/apps/docs/content/guides/auth/auth-mfa.mdx b/apps/docs/content/guides/auth/auth-mfa.mdxindex c344e974da4..9a67c33cc97 100644--- a/apps/docs/content/guides/auth/auth-mfa.mdx+++ b/apps/docs/content/guides/auth/auth-mfa.mdx@@ -80,8 +80,12 @@ An unenroll flow provides a UI for users to manage and unenroll factors linked tWhen a user unenrolls a factor, call `supabase.auth.mfa.unenroll()` with the ID of the factor. For example, call:-```-supabase.auth.mfa.unenroll({factorId: "d30fd651-184e-4748-a928-0a4b9be1d429"})+```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---+supabase.auth.mfa.unenroll({ factorId: 'd30fd651-184e-4748-a928-0a4b9be1d429' })```to unenroll a factor with ID `d30fd651-184e-4748-a928-0a4b9be1d429`.diff --git a/apps/docs/content/guides/auth/enterprise-sso/auth-sso-saml.mdx b/apps/docs/content/guides/auth/enterprise-sso/auth-sso-saml.mdxindex 16e2d9725e8..56bae4f8f16 100644--- a/apps/docs/content/guides/auth/enterprise-sso/auth-sso-saml.mdx+++ b/apps/docs/content/guides/auth/enterprise-sso/auth-sso-saml.mdx@@ -194,6 +194,10 @@ To initiate a sign-in request from your application's user interface (i.e. the S<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---supabase.auth.signInWithSSO({domain: 'company.com',})@@ -431,12 +435,16 @@ This setup allows you to implement multi-tenant SSO for multiple clients or orgaYes, also referred to as [cross-origin authentication within the same site](https://web.dev/articles/same-site-same-origin). To redirect to a URL other than the [Site URL](https://supabase.com/docs/guides/auth/redirect-urls), following the SAML response from the IdP, the `redirectTo` option can be added to [`signInWithSSO`](https://supabase.com/docs/reference/javascript/auth-signinwithsso).```ts- const { data, error } = await supabase.auth.signInWithSSO({- domain: 'company.com'- options: {- redirectTo: `https://app.company.com/callback`,- },- })+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---+const { data, error } = await supabase.auth.signInWithSSO({+ domain: 'company.com',+ options: {+ redirectTo: `https://app.company.com/callback`,+ },+})```When redirecting to a URL other than the Site URL, a `/callback` endpoint is necessary to process the auth code from the IdP and exchange it for a session. This assumes the [Supabase SSR client](https://supabase.com/docs/guides/auth/server-side/creating-a-client) has already been configured.diff --git a/apps/docs/content/guides/auth/managing-user-data.mdx b/apps/docs/content/guides/auth/managing-user-data.mdxindex 4e51dbfd93e..47022bf98f9 100644--- a/apps/docs/content/guides/auth/managing-user-data.mdx+++ b/apps/docs/content/guides/auth/managing-user-data.mdx@@ -68,6 +68,10 @@ You can assign metadata to users on sign up:<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)++// ---cut---const { data, error } = await supabase.auth.signUp({email: '[email protected]',password: 'example-password',@@ -137,10 +141,14 @@ User metadata is stored on the `raw_user_meta_data` column of the `auth.users` t<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)++// ---cut---const {data: { user },} = await supabase.auth.getUser()-let metadata = user.user_metadata+let metadata = user?.user_metadata```</TabPanel>diff --git a/apps/docs/content/guides/auth/passwords.mdx b/apps/docs/content/guides/auth/passwords.mdxindex 46bfb56c865..afdfa5b0c0b 100644--- a/apps/docs/content/guides/auth/passwords.mdx+++ b/apps/docs/content/guides/auth/passwords.mdx@@ -913,7 +913,11 @@ Once you have a session, collect the user's new password and call `updateUser` t<TabPanel id="js" label="JavaScript">```js-await supabase.auth.updateUser({ password: new_password })+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---+await supabase.auth.updateUser({ password: 'new_password' })```</TabPanel>diff --git a/apps/docs/content/guides/auth/phone-login.mdx b/apps/docs/content/guides/auth/phone-login.mdxindex e8baaf31ab3..5f6279b5a13 100644--- a/apps/docs/content/guides/auth/phone-login.mdx+++ b/apps/docs/content/guides/auth/phone-login.mdx@@ -47,6 +47,10 @@ With OTP, a user can sign in without setting a password on their account. They n<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---const { data, error } = await supabase.auth.signInWithOtp({phone: '+13334445555',})@@ -112,6 +116,10 @@ To verify the one-time password (OTP) sent to the user's phone number, call [`veYou should present a form to the user so they can input the 6 digit pin, then send it along with the phone number to `verifyOtp`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---const {data: { session },error,@@ -205,6 +213,10 @@ To update a user's phone number, the user must be logged in. Call [`updateUser()<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---const { data, error } = await supabase.auth.updateUser({phone: '123456789',})diff --git a/apps/docs/content/guides/auth/quickstarts/nextjs.mdx b/apps/docs/content/guides/auth/quickstarts/nextjs.mdxindex 9bb001cb9af..90b0bec7d26 100644--- a/apps/docs/content/guides/auth/quickstarts/nextjs.mdx+++ b/apps/docs/content/guides/auth/quickstarts/nextjs.mdx@@ -18,7 +18,7 @@ hideToc: true<StepHikeCompact.Code>- ```sql SQL_EDITOR+ ```sql name=SQL_EDITORselect * from auth.users;````@@ -41,7 +41,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx create-next-app -e with-supabase```@@ -58,7 +58,7 @@ hideToc: true<StepHikeCompact.Code>- ```text .env.local+ ```text name=.env.localNEXT_PUBLIC_SUPABASE_URL=your-project-urlNEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key```@@ -78,7 +78,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/auth/quickstarts/react-native.mdx b/apps/docs/content/guides/auth/quickstarts/react-native.mdxindex 220a8db979a..2bae82985e1 100644--- a/apps/docs/content/guides/auth/quickstarts/react-native.mdx+++ b/apps/docs/content/guides/auth/quickstarts/react-native.mdx@@ -18,7 +18,7 @@ hideToc: true<StepHikeCompact.Code>- ```sql SQL_EDITOR+ ```sql name=SQL_EDITORselect * from auth.users;````@@ -36,7 +36,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx create-expo-app -t expo-template-blank-typescript my-app```@@ -53,7 +53,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npx expo install @supabase/supabase-js @react-native-async-storage/async-storage @rneui/themed react-native-url-polyfill```@@ -70,7 +70,7 @@ hideToc: true<StepHikeCompact.Code>- ```ts lib/supabase.ts+ ```ts name=lib/supabase.tsimport { AppState } from 'react-native'import 'react-native-url-polyfill/auto'import AsyncStorage from '@react-native-async-storage/async-storage'@@ -115,7 +115,7 @@ hideToc: true<StepHikeCompact.Code>- ```tsx components/Auth.tsx+ ```tsx name=components/Auth.tsximport React, { useState } from 'react'import { Alert, StyleSheet, View } from 'react-native'import { supabase } from '../lib/supabase'@@ -214,7 +214,7 @@ hideToc: true<StepHikeCompact.Code>- ```tsx App.tsx+ ```tsx name=App.tsximport 'react-native-url-polyfill/auto'import { useState, useEffect } from 'react'import { supabase } from './lib/supabase'@@ -257,7 +257,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm start```diff --git a/apps/docs/content/guides/auth/quickstarts/react.mdx b/apps/docs/content/guides/auth/quickstarts/react.mdxindex 84cdf62d4bf..bc06bf2e736 100644--- a/apps/docs/content/guides/auth/quickstarts/react.mdx+++ b/apps/docs/content/guides/auth/quickstarts/react.mdx@@ -18,7 +18,7 @@ hideToc: true<StepHikeCompact.Code>- ```sql SQL_EDITOR+ ```sql name=SQL_EDITORselect * from auth.users;````@@ -36,7 +36,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx create-react-app my-app```@@ -55,7 +55,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npm install @supabase/supabase-js @supabase/auth-ui-react @supabase/auth-ui-shared```@@ -73,8 +73,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>-- ```js src/App.js+ ```js name=src/App.jsimport './index.css'import { useState, useEffect } from 'react'import { createClient } from '@supabase/supabase-js'@@ -122,7 +121,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm start```diff --git a/apps/docs/content/guides/auth/sessions.mdx b/apps/docs/content/guides/auth/sessions.mdxindex 90357084858..6cded62c576 100644--- a/apps/docs/content/guides/auth/sessions.mdx+++ b/apps/docs/content/guides/auth/sessions.mdx@@ -130,9 +130,15 @@ Because of this, the Supabase JavaScript libraries provide only limited support.```typescriptimport { createClient } from '@supabase/supabase-js'-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {+const supabase = createClient('SUPABASE_URL', 'SUPABASE_ANON_KEY', {auth: {- storage: customStorageObject,+ storage: {+ getItem: () => {+ return Promise.resolve('FETCHED_COOKIE')+ },+ setItem: () => {},+ removeItem: () => {},+ },},})```diff --git a/apps/docs/content/guides/auth/sessions/pkce-flow.mdx b/apps/docs/content/guides/auth/sessions/pkce-flow.mdxindex 704bc2afc43..92a4cb5fc8e 100644--- a/apps/docs/content/guides/auth/sessions/pkce-flow.mdx+++ b/apps/docs/content/guides/auth/sessions/pkce-flow.mdx@@ -26,6 +26,10 @@ For security purposes, the code has a validity of 5 minutes and can only be exchAs the flow is run server side, `localStorage` may not be available. You may configure the client library to use a custom storage adapter and an alternate backing storage such as cookies by setting the `storage` option to an object with the following methods:```js+import { type SupportedStorage } from '@supabase/supabase-js';+const supportsLocalStorage = () => true++// ---cut---const customStorageAdapter: SupportedStorage = {getItem: (key) => {if (!supportsLocalStorage()) {@@ -56,20 +60,23 @@ You may also configure the client library to automatically exchange it for a sesPutting it all together, your client library initialization may look like this:```js-const supabase = createClient(- 'https://xyzcompany.supabase.co',- 'public-anon-key',- {- ...- auth: {- ...- detectSessionInUrl: true,- flowType: 'pkce',- storage: customStorageAdapter,- }- ...- }-)+import { createClient } from '@supabase/supabase-js'++// ---cut---+const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {+ // ...+ auth: {+ // ...+ detectSessionInUrl: true,+ flowType: 'pkce',+ storage: {+ getItem: () => Promise.resolve('FETCHED_TOKEN'),+ setItem: () => {},+ removeItem: () => {},+ },+ },+ // ...+})```## Limitationsdiff --git a/apps/docs/content/guides/auth/signout.mdx b/apps/docs/content/guides/auth/signout.mdxindex 6c7f4e51bf2..fb7afec649f 100644--- a/apps/docs/content/guides/auth/signout.mdx+++ b/apps/docs/content/guides/auth/signout.mdx@@ -17,6 +17,10 @@ Call the sign out method from the client library. It removes the active session<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}@@ -77,6 +81,10 @@ You can invoke these by providing the `scope` option:<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---// defaults to the global scopeawait supabase.auth.signOut()diff --git a/apps/docs/content/guides/auth/social-login/auth-apple.mdx b/apps/docs/content/guides/auth/social-login/auth-apple.mdxindex bff18c33c89..0316b186396 100644--- a/apps/docs/content/guides/auth/social-login/auth-apple.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-apple.mdx@@ -42,6 +42,10 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,To initiate sign in, you can use the `signInWithOAuth()` method from the Supabase JavaScript library:```ts+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++ // ---cut---supabase.auth.signInWithOAuth({provider: 'apple',})@@ -127,7 +131,7 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,Follow the [Expo docs](https://docs.expo.dev/versions/latest/sdk/apple-authentication/#installation) for installation and configuration instructions. See the [supabase-js reference](/docs/reference/javascript/initializing?example=react-native-options-async-storage) for instructions on initializing the supabase-js client in React Native.- ```tsx ./components/Auth.native.tsx+ ```tsx name=./components/Auth.native.tsximport { Platform } from 'react-native'import * as AppleAuthentication from 'expo-apple-authentication'import { supabase } from 'app/utils/supabase'diff --git a/apps/docs/content/guides/auth/social-login/auth-azure.mdx b/apps/docs/content/guides/auth/social-login/auth-azure.mdxindex ee2e35a8a0c..1b31c75b679 100644--- a/apps/docs/content/guides/auth/social-login/auth-azure.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-azure.mdx@@ -130,6 +130,10 @@ Supabase Auth requires that Azure returns a valid email address. Therefore you mWhen your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `azure` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---async function signInWithAzure() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'azure',@@ -186,6 +190,10 @@ suspend fun signInWithAzure() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}@@ -230,6 +238,10 @@ Azure OAuth2.0 doesn't return the `provider_refresh_token` by default. If you ne<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---async function signInWithAzure() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'azure',diff --git a/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx b/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdxindex 583ff2caa32..50b1be00155 100644--- a/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx@@ -60,6 +60,10 @@ Setting up Bitbucket logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `bitbucket` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signInWithBitbucket() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'bitbucket',@@ -111,6 +115,10 @@ suspend fun signInWithBitbucket() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-discord.mdx b/apps/docs/content/guides/auth/social-login/auth-discord.mdxindex 62690706517..64ca269b7c4 100644--- a/apps/docs/content/guides/auth/social-login/auth-discord.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-discord.mdx@@ -59,6 +59,10 @@ Setting up Discord logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `discord` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signInWithDiscord() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'discord',@@ -112,6 +116,10 @@ If your user is already signed in, Discord prompts the user again for authorizatWhen your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-facebook.mdx b/apps/docs/content/guides/auth/social-login/auth-facebook.mdxindex 4d39e76affa..be25a4f8e10 100644--- a/apps/docs/content/guides/auth/social-login/auth-facebook.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-facebook.mdx@@ -76,6 +76,10 @@ Under `Build Your App`, click on `Use Cases` screen. From there, do the followinWhen your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `facebook` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---async function signInWithFacebook() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'facebook',@@ -147,6 +151,10 @@ suspend fun signInWithFacebook() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-figma.mdx b/apps/docs/content/guides/auth/social-login/auth-figma.mdxindex d599a25e06a..9b3701f9a9c 100644--- a/apps/docs/content/guides/auth/social-login/auth-figma.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-figma.mdx@@ -60,6 +60,10 @@ Setting up Figma logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `figma` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithFigma() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'figma',@@ -111,6 +115,10 @@ suspend fun signInWithFigma() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-github.mdx b/apps/docs/content/guides/auth/social-login/auth-github.mdxindex 54734ddc8b9..1125c1b7b7c 100644--- a/apps/docs/content/guides/auth/social-login/auth-github.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-github.mdx@@ -54,6 +54,10 @@ Copy your new OAuth credentialsWhen your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `github` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signInWithGithub() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'github',@@ -119,6 +123,10 @@ suspend fun signInWithGithub() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx b/apps/docs/content/guides/auth/social-login/auth-gitlab.mdxindex fc4a60b966c..186759e0a9a 100644--- a/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx@@ -57,6 +57,10 @@ Setting up GitLab logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `gitlab` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signInWithGitLab() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'gitlab',@@ -108,6 +112,10 @@ suspend fun signInWithGitLab() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-google.mdx b/apps/docs/content/guides/auth/social-login/auth-google.mdxindex a4985592752..5ac29b3ff11 100644--- a/apps/docs/content/guides/auth/social-login/auth-google.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-google.mdx@@ -227,6 +227,10 @@ To use your own application code for the signin button, call the `signInWithOAut<$Partial path="create_client_snippet.mdx" />```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('url', 'anonKey')++// ---cut---supabase.auth.signInWithOAuth({provider: 'google',})@@ -247,6 +251,10 @@ On initial login, you can extract the `provider_token` from the session and storGoogle does not send out a refresh token by default, so you will need to pass parameters like these to `signInWithOAuth()` in order to extract the `provider_refresh_token`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project.supabase.co', 'your-anon-key')++// ---cut---const { data, error } = await supabase.auth.signInWithOAuth({provider: 'google',options: {diff --git a/apps/docs/content/guides/auth/social-login/auth-kakao.mdx b/apps/docs/content/guides/auth/social-login/auth-kakao.mdxindex 48593424137..29dbceb668e 100644--- a/apps/docs/content/guides/auth/social-login/auth-kakao.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-kakao.mdx@@ -84,6 +84,10 @@ This will serve as the `client_id` when you make API calls to authenticate the uWhen your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `kakao` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithKakao() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'kakao',diff --git a/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx b/apps/docs/content/guides/auth/social-login/auth-keycloak.mdxindex 36677dbcf7a..48d0598698e 100644--- a/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx@@ -75,6 +75,10 @@ Since Keycloak version 22, the `openid` scope must be passed. Add this to the [`When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `keycloak` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithKeycloak() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'keycloak',@@ -153,6 +157,10 @@ Future<void> signOut() async {When your user signs out, call [signOut()](/docs/reference/kotlin/auth-signout) to remove them from the browser session and any objects from localStorage:```kotlin+import { createClient } from '@supabase/supabase-js';+const supabase = createClient('<your-project-url>', '<your-anon-key>');++// ---cut---suspend fun signOut() {supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx b/apps/docs/content/guides/auth/social-login/auth-linkedin.mdxindex e73151523da..4d1c8364493 100644--- a/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx@@ -62,6 +62,10 @@ Ensure that the appropriate scopes have been added under OAuth 2.0 Scopes at theWhen your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `linkedin_oidc` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithLinkedIn() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'linkedin_oidc',@@ -113,6 +117,10 @@ suspend fun signInWithKaLinkedIn() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-notion.mdx b/apps/docs/content/guides/auth/social-login/auth-notion.mdxindex dd4acb1ea32..d51dc093b06 100644--- a/apps/docs/content/guides/auth/social-login/auth-notion.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-notion.mdx@@ -60,6 +60,10 @@ Setting up Notion logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `notion` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithNotion() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'notion',@@ -111,6 +115,10 @@ suspend fun signInWithNotion() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-slack.mdx b/apps/docs/content/guides/auth/social-login/auth-slack.mdxindex 945349825a5..4ee888d8d09 100644--- a/apps/docs/content/guides/auth/social-login/auth-slack.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-slack.mdx@@ -78,6 +78,10 @@ Under `Scopes`:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `slack_oidc` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithSlack() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'slack_oidc',@@ -129,6 +133,10 @@ suspend fun signInWithSlack() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-spotify.mdx b/apps/docs/content/guides/auth/social-login/auth-spotify.mdxindex 62d5f898c60..403bc0fc068 100644--- a/apps/docs/content/guides/auth/social-login/auth-spotify.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-spotify.mdx@@ -72,6 +72,10 @@ The following outlines the steps to sign in using Spotify with Supabase Auth.When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `spotify` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithSpotify() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'spotify',@@ -123,6 +127,10 @@ suspend fun signInWithSpotify() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-twitch.mdx b/apps/docs/content/guides/auth/social-login/auth-twitch.mdxindex 3090a8a540f..dbb3b4458bf 100644--- a/apps/docs/content/guides/auth/social-login/auth-twitch.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-twitch.mdx@@ -75,6 +75,10 @@ Setting up Twitch logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `twitch` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithTwitch() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'twitch',@@ -126,6 +130,10 @@ suspend fun signInWithTwitch() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-twitter.mdx b/apps/docs/content/guides/auth/social-login/auth-twitter.mdxindex 69761627e3a..8c181621f0b 100644--- a/apps/docs/content/guides/auth/social-login/auth-twitter.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-twitter.mdx@@ -66,6 +66,10 @@ Setting up Twitter logins for your application consists of 3 parts:When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `twitter` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signInWithTwitter() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'twitter',@@ -117,6 +121,10 @@ suspend fun signInWithTwitter() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://your-project-id.supabase.co', 'your-anon-key')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/auth/social-login/auth-workos.mdx b/apps/docs/content/guides/auth/social-login/auth-workos.mdxindex 1abd6df0c0b..32ad6d07c67 100644--- a/apps/docs/content/guides/auth/social-login/auth-workos.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-workos.mdx@@ -53,6 +53,11 @@ On the redirects page, enter your Supabase project's `Callback URL (for OAuth)`When a user signs in, call `signInWithOAuth` with `workos` as the provider.```javascript+import { createClient } from '@supabase/supabase-js';+const supabase = createClient('<your-project-url>', '<your-anon-key>');+const redirect = (url: string) => {}++// ---cut---async function signInWithWorkOS() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'workos',diff --git a/apps/docs/content/guides/auth/social-login/auth-zoom.mdx b/apps/docs/content/guides/auth/social-login/auth-zoom.mdxindex a47a0e8ce65..24901dcee90 100644--- a/apps/docs/content/guides/auth/social-login/auth-zoom.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-zoom.mdx@@ -73,6 +73,10 @@ Under `Scopes`When your user signs in, call [`signInWithOAuth()`](/docs/reference/javascript/auth-signinwithoauth) with `zoom` as the `provider`:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signInWithZoom() {const { data, error } = await supabase.auth.signInWithOAuth({provider: 'zoom',@@ -124,6 +128,10 @@ suspend fun signInWithZoom() {When your user signs out, call [signOut()](/docs/reference/javascript/auth-signout) to remove them from the browser session and any objects from localStorage:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('<your-project-url>', '<your-anon-key>')++// ---cut---async function signOut() {const { error } = await supabase.auth.signOut()}diff --git a/apps/docs/content/guides/deployment/database-migrations.mdx b/apps/docs/content/guides/deployment/database-migrations.mdxindex 2502d360ae2..bae1145219b 100644--- a/apps/docs/content/guides/deployment/database-migrations.mdx+++ b/apps/docs/content/guides/deployment/database-migrations.mdx@@ -24,7 +24,7 @@ You will need to [install](/docs/guides/local-development#quickstart) the Supaba<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase migration new create_employees_table```@@ -44,7 +44,7 @@ supabase migration new create_employees_table<StepHikeCompact.Code>-```sql supabase/migrations/<timestamp>_create_employees_table.sql+```sql name=supabase/migrations/<timestamp>_create_employees_table.sqlcreate table if not exists employees (id bigint primary key generated always as identity,name text not null,@@ -69,7 +69,7 @@ create table if not exists employees (<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase migration up```@@ -87,7 +87,7 @@ supabase migration up<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase migration new add_department_column```@@ -105,7 +105,7 @@ supabase migration new add_department_column<StepHikeCompact.Code>-```sql supabase/migrations/<timestamp>_add_department_column.sql+```sql name=supabase/migrations/<timestamp>_add_department_column.sqlalter table if exists public.employeesadd department text default 'Hooli';```@@ -124,7 +124,7 @@ add department text default 'Hooli';<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase migration up```@@ -156,7 +156,7 @@ Now that you are managing your database with migrations scripts, it would be gre<StepHikeCompact.Code>-```sql supabase/seed.sql+```sql name=supabase/seed.sqlinsert into public.employees(name)values@@ -179,7 +179,7 @@ values<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase db reset```@@ -205,7 +205,7 @@ This workflow is great if you know SQL and are comfortable creating tables and c<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase db diff -f create_cities_table```@@ -225,7 +225,7 @@ supabase db diff -f create_cities_table<StepHikeCompact.Code>-```sql supabase/migrations/<timestamp>_create_cities_table.sql+```sql name=supabase/migrations/<timestamp>_create_cities_table.sqlcreate table "public"."cities" ("id" bigint primary key generated always as identity,"name" text,@@ -247,7 +247,7 @@ create table "public"."cities" (<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase db reset```@@ -273,7 +273,7 @@ Head over to [Supabase](https://supabase.com/dashboard) and create a new project<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase login```@@ -291,7 +291,7 @@ supabase login<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase link```@@ -309,7 +309,7 @@ supabase link<StepHikeCompact.Code>-```bash Terminal+```bash name=Terminalsupabase db push```diff --git a/apps/docs/content/guides/functions/logging.mdx b/apps/docs/content/guides/functions/logging.mdxindex 62a5cc3cd70..980ad500f11 100644--- a/apps/docs/content/guides/functions/logging.mdx+++ b/apps/docs/content/guides/functions/logging.mdx@@ -52,7 +52,7 @@ Deno.serve(async (req) => {return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } })} catch (error) {- console.error(`Error processing request: ${error.message}`)+ console.error(`Error processing request: ${error}`)return new Response(JSON.stringify({ error: 'Internal Server Error' }), {status: 500,headers: { 'Content-Type': 'application/json' },@@ -108,7 +108,7 @@ Deno.serve(async (req) => {This results in something like:-```ts index.ts+```Request headers: {"accept": "*/*","accept-encoding": "gzip",diff --git a/apps/docs/content/guides/functions/quickstart.mdx b/apps/docs/content/guides/functions/quickstart.mdxindex 8352713bdb4..2d8d1524055 100644--- a/apps/docs/content/guides/functions/quickstart.mdx+++ b/apps/docs/content/guides/functions/quickstart.mdx@@ -31,7 +31,7 @@ This will scaffold a new function for you. You can choose from Templates some ofzoomable/>-Modify the function as needed, name it, and click `Deploy function`+Modify the function as needed, name it, and click `Deploy function`.Your function is now active. Navigate to the function's details page, and click on the test button.diff --git a/apps/docs/content/guides/functions/regional-invocation.mdx b/apps/docs/content/guides/functions/regional-invocation.mdxindex 99c87b1d7c6..19fef4112b2 100644--- a/apps/docs/content/guides/functions/regional-invocation.mdx+++ b/apps/docs/content/guides/functions/regional-invocation.mdx@@ -71,7 +71,9 @@ These are the currently supported region values you can provide for `x-region` hYou can also specify the region when invoking a Function using the Supabase client library:```js-const { createClient, FunctionRegion } = require('@supabase/supabase-js')+import { createClient, FunctionRegion } from '@supabase/supabase-js'+const supabase = createClient('SUPABASE_URL', 'SUPABASE_ANON_KEY')+const { data: ret, error } = await supabase.functions.invoke('my-function-name', {headers: { 'Content-Type': 'application/json' },method: 'GET',diff --git a/apps/docs/content/guides/functions/websockets.mdx b/apps/docs/content/guides/functions/websockets.mdxindex c1c1c214319..83e134e4421 100644--- a/apps/docs/content/guides/functions/websockets.mdx+++ b/apps/docs/content/guides/functions/websockets.mdx@@ -21,30 +21,30 @@ Here are some basic examples of setting up WebSocket servers using Deno and NodequeryGroup="runtime"><TabPanel id="deno" label="Deno">+```ts- Deno.serve(req => {- const upgrade = req.headers.get("upgrade") || "";+Deno.serve((req) => {+ const upgrade = req.headers.get('upgrade') || ''- if (upgrade.toLowerCase() != "WebSocket") {- return new Response("request isn't trying to upgrade to WebSocket.", { status: 400 });- }+ if (upgrade.toLowerCase() != 'WebSocket') {+ return new Response("request isn't trying to upgrade to WebSocket.", { status: 400 })+ }- const { socket, response } = Deno.upgradeWebSocket(req);+ const { socket, response } = Deno.upgradeWebSocket(req)- socket.onopen = () => console.log("socket opened");- socket.onmessage = (e) => {- console.log("socket message:", e.data);- socket.send(new Date().toString());- };-- socket.onerror = e => console.log("socket errored:", e.message);- socket.onclose = () => console.log("socket closed");+ socket.onopen = () => console.log('socket opened')+ socket.onmessage = (e) => {+ console.log('socket message:', e.data)+ socket.send(new Date().toString())+ }- return response;+ socket.onerror = (e) => console.log('socket errored:', e.message)+ socket.onclose = () => console.log('socket closed')-});+ return response+})+```-````</TabPanel><TabPanel id="node" label="Node.js">@@ -58,13 +58,13 @@ const server = createServer();const wss = new WebSocketServer({ noServer: true });wss.on("connection", ws => {- console.log("socket opened");- ws.on("message", (data /** Buffer */, isBinary /** bool */) => {- if (isBinary) {- console.log("socket message:", data);- } else {- console.log("socket message:", data.toString());- }+console.log("socket opened");+ws.on("message", (data /** Buffer \*/, isBinary /** bool \*/) => {+if (isBinary) {+console.log("socket message:", data);+} else {+console.log("socket message:", data.toString());+}ws.send(new Date().toString());});@@ -74,15 +74,17 @@ wss.on("connection", ws => {});ws.on("close", () => console.log("socket closed"));+});server.on("upgrade", (req, socket, head) => {- wss.handleUpgrade(req, socket, head, ws => {- wss.emit("connection", ws, req);- });+wss.handleUpgrade(req, socket, head, ws => {+wss.emit("connection", ws, req);+});});server.listen(8080);+````</TabPanel>@@ -167,38 +169,39 @@ return new Response("User is not authenticated", { status: 403 });});````+</TabPanel><TabPanel id="protocol" label="Using custom protocol">```tsimport { createClient } from "jsr:@supabase/supabase-js@2";const supabase = createClient(- Deno.env.get("SUPABASE_URL"),- Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"),+Deno.env.get("SUPABASE_URL"),+Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"),);- Deno.serve(req => {- const upgrade = req.headers.get("upgrade") || "";+Deno.serve(req => {+const upgrade = req.headers.get("upgrade") || "";if (upgrade.toLowerCase() != "WebSocket") {return new Response("request isn't trying to upgrade to WebSocket.", { status: 400 });}- // Sec-WebScoket-Protocol may return multiple protocol values `jwt-TOKEN, value1, value 2`- const customProtocols = (req.headers.get("Sec-WebSocket-Protocol") ?? '').split(',').map(p => p.trim())- const jwt = customProtocols.find(p => p.startsWith('jwt')).replace('jwt-', '')- if (!jwt) {- console.error("Auth token not provided");- return new Response("Auth token not provided", { status: 403 });- }- const { error, data } = await supabase.auth.getUser(jwt);- if (error) {- console.error(error);- return new Response("Invalid token provided", { status: 403 });- }- if (!data.user) {- console.error("user is not authenticated");- return new Response("User is not authenticated", { status: 403 });- }+// Sec-WebScoket-Protocol may return multiple protocol values `jwt-TOKEN, value1, value 2`+const customProtocols = (req.headers.get("Sec-WebSocket-Protocol") ?? '').split(',').map(p => p.trim())+const jwt = customProtocols.find(p => p.startsWith('jwt')).replace('jwt-', '')+if (!jwt) {+console.error("Auth token not provided");+return new Response("Auth token not provided", { status: 403 });+}+const { error, data } = await supabase.auth.getUser(jwt);+if (error) {+console.error(error);+return new Response("Invalid token provided", { status: 403 });+}+if (!data.user) {+console.error("user is not authenticated");+return new Response("User is not authenticated", { status: 403 });+}const { socket, response } = Deno.upgradeWebSocket(req);@@ -212,7 +215,9 @@ const supabase = createClient(socket.onclose = () => console.log("socket closed");return response;- });++});+````</TabPanel>@@ -234,3 +239,4 @@ policy = "per_worker"```When running with `per_worker` policy, Function won't auto-reload on edits. You will need to manually restart it by running `supabase functions serve`.+````diff --git a/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx b/apps/docs/content/guides/getting-started/quickstarts/flutter.mdxindex aa798d48502..ec4e0efc14a 100644--- a/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/flutter.mdx@@ -23,7 +23,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalflutter create my_app```@@ -43,7 +43,7 @@ hideToc: true<StepHikeCompact.Code>- ```yaml pubspec.yaml+ ```yaml name=pubspec.yamlsupabase_flutter: ^2.0.0```@@ -64,7 +64,7 @@ hideToc: true<StepHikeCompact.Code>- ```dart lib/main.dart+ ```dart name=lib/main.dartimport 'package:supabase_flutter/supabase_flutter.dart';Future<void> main() async {@@ -94,7 +94,7 @@ hideToc: true<StepHikeCompact.Code>- ```dart lib/main.dart+ ```dart name=lib/main.dartclass MyApp extends StatelessWidget {const MyApp({super.key});@@ -161,7 +161,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalflutter run```diff --git a/apps/docs/content/guides/getting-started/quickstarts/hono.mdx b/apps/docs/content/guides/getting-started/quickstarts/hono.mdxindex be46310e9b3..d85823d1998 100644--- a/apps/docs/content/guides/getting-started/quickstarts/hono.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/hono.mdx@@ -17,7 +17,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx supabase@latest bootstrap hono```@@ -34,7 +34,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm install```@@ -56,7 +56,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcp .env.example .env```@@ -75,7 +75,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx b/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdxindex fdd5b4ea964..6e245725384 100644--- a/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/ios-swiftui.mdx@@ -48,7 +48,7 @@ hideToc: true<StepHikeCompact.Code>- ```swift Supabase.swift+ ```swift name=Supabase.swiftimport Supabaselet supabase = SupabaseClient(@@ -73,7 +73,7 @@ hideToc: true<StepHikeCompact.Code>- ```swift Supabase.swift+ ```swift name=Supabase.swiftstruct Instrument: Decodable, Identifiable {let id: Intlet name: String@@ -96,7 +96,7 @@ hideToc: true<StepHikeCompact.Code>- ```swift ContentView.swift+ ```swift name=ContentView.swiftstruct ContentView: View {@State var instruments: [Instrument] = []diff --git a/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx b/apps/docs/content/guides/getting-started/quickstarts/laravel.mdxindex c2b95516c01..22c36d4dec9 100644--- a/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/laravel.mdx@@ -18,7 +18,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcomposer create-project laravel/laravel example-app```@@ -35,7 +35,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcomposer require laravel/breeze --devphp artisan breeze:install```@@ -61,7 +61,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash .env+ ```bash name=.envDB_CONNECTION=pgsqlDB_URL=postgres://postgres.xxxx:[email protected]:5432/postgres```@@ -83,7 +83,7 @@ hideToc: true<StepHikeCompact.Code>- ```php app/config/database.php+ ```php name=app/config/database.php'pgsql' => ['driver' => 'pgsql','url' => env('DB_URL'),@@ -115,7 +115,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalphp artisan migrate```@@ -132,7 +132,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalphp artisan serve```diff --git a/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdxindex 594725e8d71..a6633706faa 100644--- a/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx@@ -84,35 +84,35 @@ hideToc: true``````ts name=utils/supabase/server.ts- import { createServerClient } from '@supabase/ssr'- import { cookies } from 'next/headers'-- export async function createClient() {- const cookieStore = await cookies()-- return createServerClient(- process.env.NEXT_PUBLIC_SUPABASE_URL!,- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,- {- cookies: {- getAll() {- return cookieStore.getAll()- },- setAll(cookiesToSet) {- try {- cookiesToSet.forEach(({ name, value, options }) =>- cookieStore.set(name, value, options)- )- } catch {- // The `setAll` method was called from a Server Component.- // This can be ignored if you have middleware refreshing- // user sessions.- }- },+ import { createServerClient } from '@supabase/ssr'+ import { cookies } from 'next/headers'++ export async function createClient() {+ const cookieStore = await cookies()++ return createServerClient(+ process.env.NEXT_PUBLIC_SUPABASE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,+ {+ cookies: {+ getAll() {+ return cookieStore.getAll()},- }- )- }+ setAll(cookiesToSet) {+ try {+ cookiesToSet.forEach(({ name, value, options }) =>+ cookieStore.set(name, value, options)+ )+ } catch {+ // The `setAll` method was called from a Server Component.+ // This can be ignored if you have middleware refreshing+ // user sessions.+ }+ },+ },+ }+ )+ }```</$CodeTabs>diff --git a/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdxindex 8a6462849e7..6e19c64f2ed 100644--- a/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/nuxtjs.mdx@@ -23,7 +23,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx nuxi@latest init my-app```@@ -42,7 +42,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npm install @supabase/supabase-js```@@ -64,7 +64,7 @@ hideToc: true<StepHikeCompact.Code>- ```vue app.vue+ ```vue name=app.vue<script setup>import { createClient } from '@supabase/supabase-js'const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')@@ -100,7 +100,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdxindex 05a5eeaccec..984acb8f8f2 100644--- a/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/reactjs.mdx@@ -23,7 +23,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm create vite@latest my-app -- --template react```@@ -42,7 +42,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npm install @supabase/supabase-js```@@ -63,35 +63,34 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>+ ```js name=src/App.jsx+ import { useEffect, useState } from "react";+ import { createClient } from "@supabase/supabase-js";- ```js src/App.jsx- import { useEffect, useState } from "react";- import { createClient } from "@supabase/supabase-js";+ const supabase = createClient("https://<project>.supabase.co", "<your-anon-key>");- const supabase = createClient("https://<project>.supabase.co", "<your-anon-key>");+ function App() {+ const [instruments, setInstruments] = useState([]);- function App() {- const [instruments, setInstruments] = useState([]);+ useEffect(() => {+ getInstruments();+ }, []);- useEffect(() => {- getInstruments();- }, []);-- async function getInstruments() {- const { data } = await supabase.from("instruments").select();- setInstruments(data);- }-- return (- <ul>- {instruments.map((instrument) => (- <li key={instrument.name}>{instrument.name}</li>- ))}- </ul>- );+ async function getInstruments() {+ const { data } = await supabase.from("instruments").select();+ setInstruments(data);}- export default App;+ return (+ <ul>+ {instruments.map((instrument) => (+ <li key={instrument.name}>{instrument.name}</li>+ ))}+ </ul>+ );+ }++ export default App;```</StepHikeCompact.Code>@@ -107,7 +106,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdxindex 62262e80c1d..4d88e8989d7 100644--- a/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/redwoodjs.mdx@@ -64,7 +64,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalyarn create redwood-app my-app --ts```</StepHikeCompact.Code>@@ -77,7 +77,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-appcode .```@@ -97,7 +97,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash .env+ ```bash name=.env# Transaction mode connection string used for migrationsDATABASE_URL="postgres://postgres.[project-ref]:[db-password]@xxx.pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=1"@@ -116,7 +116,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```prisma api/db/schema.prisma+ ```prisma name=api/db/schema.prismadatasource db {provider = "postgresql"url = env("DATABASE_URL")@@ -133,7 +133,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```prisma api/db/schema.prisma+ ```prisma name=api/db/schema.prismamodel Instrument {id Int @id @default(autoincrement())name String @unique@@ -152,7 +152,7 @@ hideToc: true<StepHikeCompact.Code>- ```ts scripts/seed.ts+ ```ts name=scripts/seed.tsimport type { Prisma } from '@prisma/client'import { db } from 'api/src/lib/db'@@ -190,7 +190,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalyarn rw prisma db seed```</StepHikeCompact.Code>@@ -203,7 +203,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalyarn rw g scaffold instrument```</StepHikeCompact.Code>diff --git a/apps/docs/content/guides/getting-started/quickstarts/refine.mdx b/apps/docs/content/guides/getting-started/quickstarts/refine.mdxindex a6341037381..da4656c9f42 100644--- a/apps/docs/content/guides/getting-started/quickstarts/refine.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/refine.mdx@@ -25,7 +25,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm create refine-app@latest -- --preset refine-supabase my-app```@@ -42,7 +42,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-appcode .```@@ -60,7 +60,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```@@ -84,7 +84,7 @@ hideToc: true<StepHikeCompact.Code>- ```ts src/utility/supabaseClient.ts+ ```ts name=src/utility/supabaseClient.tsimport { createClient } from "@refinedev/supabase";const SUPABASE_URL = YOUR_SUPABASE_URL;@@ -128,7 +128,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run refine create-resource instruments```</StepHikeCompact.Code>@@ -149,7 +149,7 @@ hideToc: true</StepHikeCompact.Details><StepHikeCompact.Code>- ```tsx src/App.tsx+ ```tsx name=src/App.tsximport { Refine, WelcomePage } from "@refinedev/core";import { RefineKbar, RefineKbarProvider } from "@refinedev/kbar";import routerBindings, {diff --git a/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx b/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdxindex 29da0803dad..ffe60f4bf65 100644--- a/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx@@ -18,7 +18,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalrails new blog -d=postgresql```@@ -43,7 +43,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalexport DATABASE_URL=postgres://postgres.xxxx:[email protected]:5432/postgres```@@ -62,7 +62,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalbin/rails generate model Article title:string body:textbin/rails db:migrate```@@ -80,11 +80,11 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalbin/rails console```- ```rb irb+ ```rb name=irbarticle = Article.new(title: "Hello Rails", body: "I am on Rails!")article.save # Saves the entry to the database@@ -104,7 +104,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalbin/rails server```diff --git a/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdxindex 3bdc70249e1..8f417f15ed5 100644--- a/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/solidjs.mdx@@ -23,7 +23,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx degit solidjs/templates/js my-app```@@ -42,7 +42,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npm install @supabase/supabase-js```@@ -64,7 +64,7 @@ hideToc: true<StepHikeCompact.Code>- ```jsx src/App.jsx+ ```jsx name=src/App.jsximport { createClient } from "@supabase/supabase-js";import { createResource, For } from "solid-js";@@ -101,7 +101,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx b/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdxindex 300005e3c7d..0dcbef0201c 100644--- a/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/sveltekit.mdx@@ -23,7 +23,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpx sv create my-app```@@ -42,7 +42,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npm install @supabase/supabase-js```@@ -62,7 +62,7 @@ hideToc: true<StepHikeCompact.Code>- ```js src/lib/supabaseClient.js+ ```js name=src/lib/supabaseClient.jsimport { createClient } from '@supabase/supabase-js'export const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')@@ -83,7 +83,7 @@ hideToc: true<StepHikeCompact.Code>- ```js src/routes/+page.server.js+ ```js name=src/routes/+page.server.jsimport { supabase } from "$lib/supabaseClient";export async function load() {@@ -104,7 +104,7 @@ hideToc: true<StepHikeCompact.Code>- ```svelte src/routes/+page.svelte+ ```svelte name=src/routes/+page.svelte<script>let { data } = $props();</script>@@ -129,7 +129,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/getting-started/quickstarts/vue.mdx b/apps/docs/content/guides/getting-started/quickstarts/vue.mdxindex 27cc48ce9cd..70ee2467cac 100644--- a/apps/docs/content/guides/getting-started/quickstarts/vue.mdx+++ b/apps/docs/content/guides/getting-started/quickstarts/vue.mdx@@ -23,7 +23,7 @@ hideToc: true<StepHikeCompact.Code>- ```sh Terminal+ ```sh name=Terminalnpm init vue@latest my-app```@@ -42,7 +42,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalcd my-app && npm install @supabase/supabase-js```@@ -62,10 +62,10 @@ hideToc: true<StepHikeCompact.Code>- ```js src/lib/supabaseClient.js- import { createClient } from '@supabase/supabase-js'+ ```js name=src/lib/supabaseClient.js+ import { createClient } from '@supabase/supabase-js'- export const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')+ export const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')```</StepHikeCompact.Code>@@ -81,28 +81,28 @@ hideToc: true<StepHikeCompact.Code>- ```vue src/App.vue- <script setup>- import { ref, onMounted } from 'vue'- import { supabase } from './lib/supabaseClient'+ ```vue name=src/App.vue+ <script setup>+ import { ref, onMounted } from 'vue'+ import { supabase } from './lib/supabaseClient'- const instruments = ref([])+ const instruments = ref([])- async function getInstruments() {- const { data } = await supabase.from('instruments').select()- instruments.value = data- }+ async function getInstruments() {+ const { data } = await supabase.from('instruments').select()+ instruments.value = data+ }- onMounted(() => {- getInstruments()- })- </script>+ onMounted(() => {+ getInstruments()+ })+ </script>- <template>- <ul>- <li v-for="instrument in instruments" :key="instrument.id">{{ instrument.name }}</li>- </ul>- </template>+ <template>+ <ul>+ <li v-for="instrument in instruments" :key="instrument.id">{{ instrument.name }}</li>+ </ul>+ </template>```</StepHikeCompact.Code>@@ -118,7 +118,7 @@ hideToc: true<StepHikeCompact.Code>- ```bash Terminal+ ```bash name=Terminalnpm run dev```diff --git a/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx b/apps/docs/content/guides/getting-started/tutorials/with-refine.mdxindex 159d8bceec3..2d8812515b1 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx@@ -160,7 +160,7 @@ If you examine the `authProvider` object you can notice that it has a `login` meWe want to use `supabaseClient` auth's `signInWithOtp` method inside `authProvider.login` method:-```ts+```ts name=src/authProvider.tslogin: async ({ email }) => {try {const { error } = await supabaseClient.auth.signInWithOtp({ email });diff --git a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdxindex 333c69c04e5..1b114f50a60 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx@@ -553,7 +553,7 @@ Create a new `src/routes/account/+page.svelte` file with the content below.Now create the associated `src/routes/account/+page.server.ts` file that will handle loading our data from the server through the `load` functionand handle all our form actions through the `actions` object.-```ts+```ts name=src/routes/account/+page.server.tsimport { fail, redirect } from '@sveltejs/kit'import type { Actions, PageServerLoad } from './$types'diff --git a/apps/docs/content/guides/local-development/overview.mdx b/apps/docs/content/guides/local-development/overview.mdxindex cdec153bc1b..d399cabc9fc 100644--- a/apps/docs/content/guides/local-development/overview.mdx+++ b/apps/docs/content/guides/local-development/overview.mdx@@ -39,7 +39,7 @@ For this guide, we'll create a table called `employees` and see how we can make<StepHikeCompact.Code>-```bash+```bash name=Terminalsupabase migration new create_employees_table```@@ -59,26 +59,21 @@ supabase migration new create_employees_table</StepHikeCompact.Details><StepHikeCompact.Code>- ```sql--create table-employees (-id bigint primary key generated always as identity,-name text,-email text,-created_at timestamptz default now()-);-````+```sql name=20250101000000_create_employees_table.sql+create table employees (+ id bigint primary key generated always as identity,+ name text,+ email text,+ created_at timestamptz default now()+);+```</StepHikeCompact.Code></StepHikeCompact.Step></StepHikeCompact>---<StepHikeCompact><StepHikeCompact.Step step={3}>@@ -89,9 +84,10 @@ created_at timestamptz default now()</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash++```bash name=Terminalsupabase db reset-````+```</StepHikeCompact.Code>@@ -108,17 +104,16 @@ supabase db reset</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash- supabase migration new add_department_to_employees_table-````+```bash name=Terminal+supabase migration new add_department_to_employees_table+```+</StepHikeCompact.Code></StepHikeCompact.Step></StepHikeCompact>--<StepHikeCompact><StepHikeCompact.Step step={5}>@@ -130,10 +125,11 @@ supabase db reset</StepHikeCompact.Details><StepHikeCompact.Code>- ```sql-alter table- if exists public.employees add department text default 'Hooli';-````++```sql name=20250101000001_add_department_to_employees_table.sql+alter table if exists public.employees+add department text default 'Hooli';+```</StepHikeCompact.Code>@@ -154,23 +150,21 @@ For this, you can create a seed script in `supabase/seed.sql`.</StepHikeCompact.Details><StepHikeCompact.Code>- ```sql--- in supabase/seed.sql-insert into-public.employees (name)+```sql name=supabase/seed.sql+insert into public.employees+ (name)values-('Erlich Bachman'),-('Richard Hendricks'),-('Monica Hall');+ ('Erlich Bachman'),+ ('Richard Hendricks'),+ ('Monica Hall');+```-````</StepHikeCompact.Code></StepHikeCompact.Step></StepHikeCompact>-<StepHikeCompact><StepHikeCompact.Step step={2}>@@ -179,9 +173,10 @@ values</StepHikeCompact.Details><StepHikeCompact.Code>- ```bash++```bash name=Terminalsupabase db reset-````+```</StepHikeCompact.Code>diff --git a/apps/docs/content/guides/platform/migrating-to-supabase/auth0.mdx b/apps/docs/content/guides/platform/migrating-to-supabase/auth0.mdxindex 06aaa03398c..48534360ffe 100644--- a/apps/docs/content/guides/platform/migrating-to-supabase/auth0.mdx+++ b/apps/docs/content/guides/platform/migrating-to-supabase/auth0.mdx@@ -79,6 +79,10 @@ Migrate existing users to Supabase Auth. This requires two main steps: first, ch1. Use Supabase Auth's [admin create user](/docs/reference/javascript/auth-admin-createuser) method to recreate the user in Supabase Auth. If the user has a confirmed email address or phone number, set `email_confirm` or `phone_confirm` to `true`.```ts+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('your_project_url', 'your_supabase_api_key')++ // ---cut---const { data, error } = await supabase.auth.admin.createUser({email: '[email protected]',password_hash: '$2y$10$a9pghn27d7m0ltXvlX8LiOowy7XfFw0hW0G80OjKYQ1jaoejaA7NC',@@ -95,6 +99,10 @@ Migrate existing users to Supabase Auth. This requires two main steps: first, chIf you have a plaintext password instead of a hash, you can provide that instead. Supabase Auth will handle hashing the password for you. (Passwords are **always** stored hashed.)```ts+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('your_project_url', 'your_supabase_api_key')++ // ---cut---const { data, error } = await supabase.auth.admin.createUser({email: '[email protected]',password: 'supersecurepassword123!',@@ -114,6 +122,10 @@ Migrate existing users to Supabase Auth. This requires two main steps: first, chFor passwordless signin via email or phone, check for users with verified email addresses or phone numbers. Create these users in Supabase Auth with `email_confirm` or `phone_confirm` set to `true`:```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const { data, error } = await supabase.auth.admin.createUser({email: '[email protected]',email_confirm: true,@@ -150,6 +162,10 @@ Supabase Auth provides 2 fields which you can use to map user-specific metadataBoth columns are accessible from the admin user methods. To create a user with custom metadata, you can use the following method:```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const { data, error } = await supabase.auth.admin.createUser({email: '[email protected]',user_metadata: {diff --git a/apps/docs/content/guides/realtime/authorization.mdx b/apps/docs/content/guides/realtime/authorization.mdxindex 9f72dc4dc39..3dce5b919f7 100644--- a/apps/docs/content/guides/realtime/authorization.mdx+++ b/apps/docs/content/guides/realtime/authorization.mdx@@ -132,6 +132,10 @@ Then, to join a topic with RLS enabled, instantiate the Channel with the `privat><TabPanel id="js" label="JavaScript">```javascript+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('your_project_url', 'your_supabase_api_key')++ // ---cut---const channel = supabase.channel('room-1', {config: { private: true },})diff --git a/apps/docs/content/guides/realtime/broadcast.mdx b/apps/docs/content/guides/realtime/broadcast.mdxindex 0a59bd2a1a8..abc206aa9ce 100644--- a/apps/docs/content/guides/realtime/broadcast.mdx+++ b/apps/docs/content/guides/realtime/broadcast.mdx@@ -101,6 +101,11 @@ You can provide a callback for the `broadcast` channel to receive message. This{/* prettier-ignore */}```js+ // @noImplicitAny: false+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')++ // ---cut---// Join a room/topic. Can be anything except for 'realtime'.const myChannel = supabase.channel('test-channel')@@ -210,6 +215,10 @@ You can use the Supabase client libraries to send Broadcast messages.{/* prettier-ignore */}```js+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('your_project_url', 'your_supabase_api_key')++ // ---cut---const myChannel = supabase.channel('test-channel')/**@@ -576,6 +585,10 @@ You can pass configuration options while initializing the Supabase Client.{/* prettier-ignore */}```js+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('your_project_url', 'your_supabase_api_key')++ // ---cut---const myChannel = supabase.channel('room-3', {config: {broadcast: { ack: true },diff --git a/apps/docs/content/guides/realtime/concepts.mdx b/apps/docs/content/guides/realtime/concepts.mdxindex cf8c56684e6..867a53f4a05 100644--- a/apps/docs/content/guides/realtime/concepts.mdx+++ b/apps/docs/content/guides/realtime/concepts.mdx@@ -31,6 +31,11 @@ const roomOne = supabase.channel('room-one') // set your topic hereRealtime Broadcast follows the [publish-subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) where a client publishes messages to a channel based on a unique topic. For example, a user could send a message to a channel with topic `room-one`.```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')+const roomOne = supabase.channel('room-one') // set your topic here++// ---cut---roomOne.send({type: 'broadcast',event: 'test',@@ -47,6 +52,11 @@ An example use-case is sharing a user's cursor position with other clients in anPresence can be used to share an individual's state with others within a Channel.```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')+const roomOne = supabase.channel('room-one') // set your topic here++// ---cut---const presenceTrackStatus = await roomOne.track({user: 'user-1',online_at: new Date().toISOString(),@@ -62,6 +72,10 @@ When a new client subscribes to a channel, it will immediately receive the channThe Postgres Changes extension listens for database changes and sends them to clients. Clients are required to subscribe with a JWT dictating which changes they are allowed to receive based on the database's [Row Level Security](/docs/guides/database/postgres/row-level-security).```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const allChanges = supabase.channel('schema-db-changes').on(diff --git a/apps/docs/content/guides/realtime/postgres-changes.mdx b/apps/docs/content/guides/realtime/postgres-changes.mdxindex 8f0120e196d..a75c940404d 100644--- a/apps/docs/content/guides/realtime/postgres-changes.mdx+++ b/apps/docs/content/guides/realtime/postgres-changes.mdx@@ -106,7 +106,7 @@ In this example we'll set up a database table, secure it with Row Level Security<StepHikeCompact.Code>```bash- npm install @supabase/supabase-js+ npm install @supabase/supabase-js```</StepHikeCompact.Code>@@ -124,12 +124,12 @@ In this example we'll set up a database table, secure it with Row Level Security<StepHikeCompact.Code>```js- import { createClient } from '@supabase/supabase-js'+ import { createClient } from '@supabase/supabase-js'- const supabase = createClient(- 'https://<project>.supabase.co',- '<your-anon-key>'- )+ const supabase = createClient(+ 'https://<project>.supabase.co',+ '<your-anon-key>'+ )```</StepHikeCompact.Code>@@ -152,17 +152,21 @@ In this example we'll set up a database table, secure it with Row Level Security<StepHikeCompact.Code>```js- const channelA = supabase- .channel('schema-db-changes')- .on(- 'postgres_changes',- {- event: '*',- schema: 'public',- },- (payload) => console.log(payload)- )- .subscribe()+ import { createClient } from '@supabase/supabase-js'+ const supabase = createClient('your_project_url', 'your_supabase_api_key')++ // ---cut---+ const channelA = supabase+ .channel('schema-db-changes')+ .on(+ 'postgres_changes',+ {+ event: '*',+ schema: 'public',+ },+ (payload) => console.log(payload)+ )+ .subscribe()```</StepHikeCompact.Code>diff --git a/apps/docs/content/guides/realtime/presence.mdx b/apps/docs/content/guides/realtime/presence.mdxindex e7710fc4614..f545643cb2d 100644--- a/apps/docs/content/guides/realtime/presence.mdx+++ b/apps/docs/content/guides/realtime/presence.mdx@@ -99,6 +99,10 @@ supabase = create_client(SUPABASE_URL, SUPABASE_KEY)Listen to the `sync`, `join`, and `leave` events triggered whenever any client joins or leaves the channel or changes their slice of state:```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const roomOne = supabase.channel('room_01')roomOne@@ -201,6 +205,10 @@ You can send state to all subscribers using `track()`:{/* prettier-ignore */}```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const roomOne = supabase.channel('room_01')const userStatus = {@@ -315,6 +323,11 @@ You can stop tracking presence using the `untrack()` method. This will trigger t<TabPanel id="js" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')+const roomOne = supabase.channel('room_01')++// ---cut---const untrackPresence = async () => {const presenceUntrackStatus = await roomOne.untrack()console.log(presenceUntrackStatus)@@ -384,6 +397,7 @@ By default, Presence will generate a unique `UUIDv1` key on the server to track```jsimport { createClient } from '@supabase/supabase-js'+const supabase = createClient('SUPABASE_URL', 'SUPABASE_ANON_KEY')const channelC = supabase.channel('test', {config: {diff --git a/apps/docs/content/guides/realtime/subscribing-to-database-changes.mdx b/apps/docs/content/guides/realtime/subscribing-to-database-changes.mdxindex d15ec3d4bbc..e766cc30c97 100644--- a/apps/docs/content/guides/realtime/subscribing-to-database-changes.mdx+++ b/apps/docs/content/guides/realtime/subscribing-to-database-changes.mdx@@ -70,7 +70,11 @@ execute function your_table_changes ();Finally, on the client side, listen to the topic `topic:<record_id>` to receive the events. Remember to set the channel as a private channel, since `realtime.broadcast_changes` uses Realtime Authorization.-```jsx+```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const gameId = 'id'await supabase.realtime.setAuth() // Needed for Realtime Authorizationconst changes = supabase@@ -122,10 +126,11 @@ alterYou can use the `INSERT` event to stream all new rows.```js+// @noImplicitAny: falseimport { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')-const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY)-+// ---cut---const channel = supabase.channel('schema-db-changes').on(@@ -144,10 +149,11 @@ const channel = supabaseYou can use the `UPDATE` event to stream all updated rows.```js+// @noImplicitAny: falseimport { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')-const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY)-+// ---cut---const channel = supabase.channel('schema-db-changes').on(diff --git a/apps/docs/content/guides/storage/buckets/creating-buckets.mdx b/apps/docs/content/guides/storage/buckets/creating-buckets.mdxindex b441adc2a91..2dff4d0d540 100644--- a/apps/docs/content/guides/storage/buckets/creating-buckets.mdx+++ b/apps/docs/content/guides/storage/buckets/creating-buckets.mdx@@ -18,6 +18,10 @@ Here we create a bucket called "avatars":<TabPanel id="javascript" label="JavaScript">```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)++// ---cut---// Use the JS library to create a bucket.const { data, error } = await supabase.storage.createBucket('avatars', {@@ -97,6 +101,10 @@ For example, imagine you want to allow your users to upload only images to the `You can achieve the following by providing: `allowedMimeTypes` and `maxFileSize````js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!)++// ---cut---// Use the JS library to create a bucket.const { data, error } = await supabase.storage.createBucket('avatars', {diff --git a/apps/docs/content/guides/storage/management/copy-move-objects.mdx b/apps/docs/content/guides/storage/management/copy-move-objects.mdxindex 26bf21eab08..be357fce7e0 100644--- a/apps/docs/content/guides/storage/management/copy-move-objects.mdx+++ b/apps/docs/content/guides/storage/management/copy-move-objects.mdx@@ -17,6 +17,10 @@ When making a copy of an object, the owner of the new object will be the user whTo copy an object within the same bucket, use the `copy` method.```javascript+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---await supabase.storage.from('avatars').copy('public/avatar1.png', 'private/avatar2.png')```@@ -25,6 +29,10 @@ await supabase.storage.from('avatars').copy('public/avatar1.png', 'private/avataTo copy an object across buckets, use the `copy` method and specify the destination bucket.```javascript+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---await supabase.storage.from('avatars').copy('public/avatar1.png', 'private/avatar2.png', {destinationBucket: 'avatars2',})@@ -41,6 +49,10 @@ When moving an object, the owner of the new object will be the user who initiateTo move an object within the same bucket, you can use the `move` method.```javascript+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const { data, error } = await supabase.storage.from('avatars').move('public/avatar1.png', 'private/avatar2.png')@@ -51,6 +63,10 @@ const { data, error } = await supabase.storageTo move an object across buckets, use the `move` method and specify the destination bucket.```javascript+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---await supabase.storage.from('avatars').move('public/avatar1.png', 'private/avatar2.png', {destinationBucket: 'avatars2',})diff --git a/apps/docs/content/guides/storage/management/delete-objects.mdx b/apps/docs/content/guides/storage/management/delete-objects.mdxindex 8f5fc34b81a..0565ad84ff1 100644--- a/apps/docs/content/guides/storage/management/delete-objects.mdx+++ b/apps/docs/content/guides/storage/management/delete-objects.mdx@@ -19,6 +19,10 @@ Deleting objects should always be done via the **Storage API** and NOT via a **STo delete one or more objects, use the `remove` method.```javascript+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---await supabase.storage.from('bucket').remove(['object-path-2', 'folder/avatar2.png'])```diff --git a/apps/docs/content/guides/storage/serving/downloads.mdx b/apps/docs/content/guides/storage/serving/downloads.mdxindex 88055fd63f7..6f2c891c066 100644--- a/apps/docs/content/guides/storage/serving/downloads.mdx+++ b/apps/docs/content/guides/storage/serving/downloads.mdx@@ -20,6 +20,10 @@ https://[project_id].supabase.co/storage/v1/object/public/[bucket]/[asset-name]You can also use the Supabase SDK `getPublicUrl` to generate this URL for you```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const { data } = supabase.storage.from('bucket').getPublicUrl('filePath.jpg')console.log(data.publicUrl)@@ -45,6 +49,10 @@ You can access them only by:You can sign a time-limited URL that you can share to your users by invoking the `createSignedUrl` method on the SDK.```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---const { data, error } = await supabase.storage.from('bucket').createSignedUrl('private-document.pdf', 3600)diff --git a/apps/docs/content/guides/storage/serving/image-transformations.mdx b/apps/docs/content/guides/storage/serving/image-transformations.mdxindex feebfbb1d72..504eb13c300 100644--- a/apps/docs/content/guides/storage/serving/image-transformations.mdx+++ b/apps/docs/content/guides/storage/serving/image-transformations.mdx@@ -29,6 +29,10 @@ Our client libraries methods like `getPublicUrl` and `createSignedUrl` support t<TabPanel id="js" label="JavaScript">```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---supabase.storage.from('bucket').getPublicUrl('image.jpg', {transform: {width: 500,@@ -108,6 +112,10 @@ To share a transformed image in a private bucket for a fixed amount of time, pro<TabPanel id="js" label="JavaScript">```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---supabase.storage.from('bucket').createSignedUrl('image.jpg', 60000, {transform: {width: 200,@@ -173,6 +181,10 @@ To download a transformed image, pass the `transform` option to the `download` f<TabPanel id="js" label="JavaScript">```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---supabase.storage.from('bucket').download('image.jpg', {transform: {width: 800,@@ -269,6 +281,10 @@ In case you'd like to return the original format of the image and **opt-out** fr<TabPanel id="js" label="JavaScript">```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---await supabase.storage.from('bucket').download('image.jpeg', {transform: {width: 200,@@ -402,6 +418,10 @@ Example:<TabPanel id="js" label="JavaScript">```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---supabase.storage.from('bucket').download('image.jpg', {transform: {quality: 50,@@ -498,6 +518,10 @@ Example:<TabPanel id="js" label="JavaScript">```ts+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// ---cut---supabase.storage.from('bucket').download('image.jpg', {transform: {width: 800,diff --git a/apps/docs/content/guides/storage/uploads/standard-uploads.mdx b/apps/docs/content/guides/storage/uploads/standard-uploads.mdxindex 71302bd9089..fdde4e31fb7 100644--- a/apps/docs/content/guides/storage/uploads/standard-uploads.mdx+++ b/apps/docs/content/guides/storage/uploads/standard-uploads.mdx@@ -28,6 +28,9 @@ Though you can upload up to 5GB files using the standard upload method, we recom<TabPanel id="js" label="JavaScript">```javascript+// @noImplicitAny: false++// ---cut---import { createClient } from '@supabase/supabase-js'// Create Supabase client@@ -101,6 +104,10 @@ If you want to overwrite a file on a specific path you can set the `upsert` opti<TabPanel id="js" label="JavaScript">```javascript+import { createClient } from '@supabase/supabase-js'+const file = new Blob()++// ---cut---// Create Supabase clientconst supabase = createClient('your_project_url', 'your_supabase_api_key')@@ -177,6 +184,10 @@ By default, Storage will assume the content type of an asset from the file exten<TabPanel id="js" label="JavaScript">```javascript+import { createClient } from '@supabase/supabase-js'+const file = new Blob()++// ---cut---// Create Supabase clientconst supabase = createClient('your_project_url', 'your_supabase_api_key')diff --git a/apps/docs/features/directives/CodeTabs.components.tsx b/apps/docs/features/directives/CodeTabs.components.tsxnew file mode 100644index 00000000000..757eb6b2e94--- /dev/null+++ b/apps/docs/features/directives/CodeTabs.components.tsx@@ -0,0 +1,21 @@+import { type PropsWithChildren } from 'react'++import { cn } from 'ui'++export function NamedCodeBlock({ name, children }: PropsWithChildren<{ name: string }>) {+ return (+ <div className="shiki-wrapper w-full space-y-2">+ <h6+ className={cn(+ 'w-fit flex items-center text-center',+ 'shadow-sm rounded border border-stronger bg-selection',+ 'px-2.5 py-1',+ 'text-xs text-foreground'+ )}+ >+ {name}+ </h6>+ {children}+ </div>+ )+}diff --git a/apps/docs/features/directives/CodeTabs.test.ts b/apps/docs/features/directives/CodeTabs.test.tsindex be0a45bb2a4..c69d8199be5 100644--- a/apps/docs/features/directives/CodeTabs.test.ts+++ b/apps/docs/features/directives/CodeTabs.test.ts@@ -62,4 +62,33 @@ console.log('Hello, world!');const mdast = fromDocsMarkdown(mdx)expect(() => codeTabsRemark()(mdast)).toThrowError()})++ it('should add a name to a code block outside of CodeTabs if meta present', () => {+ const mdx = `+\`\`\`js name=a.js+console.log('Hello, world!');+\`\`\`++\`\`\`js+console.log('Hello, world!');+\`\`\`+`.trim()+ const mdast = fromDocsMarkdown(mdx)+ const transformed = codeTabsRemark()(mdast)+ const output = toMarkdown(transformed, { extensions: [mdxToMarkdown()] })++ expect(output).toEqual(+ `+<NamedCodeBlock name="a.js">+ \`\`\`js name=a.js+ console.log('Hello, world!');+ \`\`\`+</NamedCodeBlock>++\`\`\`js+console.log('Hello, world!');+\`\`\`+`.trimStart()+ )+ })})diff --git a/apps/docs/features/directives/CodeTabs.ts b/apps/docs/features/directives/CodeTabs.tsindex 71ee9aa893c..6fc79271f70 100644--- a/apps/docs/features/directives/CodeTabs.ts+++ b/apps/docs/features/directives/CodeTabs.ts@@ -21,7 +21,7 @@import { type Parent, type Code, type Root } from 'mdast'import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx'-import { visitParents } from 'unist-util-visit-parents'+import { SKIP, visitParents } from 'unist-util-visit-parents'import { isCodeSampleWrapper } from './CodeSample'@@ -33,52 +33,90 @@ export function codeTabsRemark() {}function rewriteNodes(tree: Root) {- visitParents(tree, 'mdxJsxFlowElement', (node: MdxJsxFlowElement, ancestors: Array<Parent>) => {- if (node.name !== '$CodeTabs') return- if (node.children.some((child) => child.type !== 'code' && !isCodeSampleWrapper(child))) {- throw new Error(- `CodeTabs must contain only code blocks and code sample wrappers, found:\n\n${JSON.stringify(node.children, null, 2)}`- )- }-- const parent = ancestors[ancestors.length - 1]- const remappedChildren = node.children.map(- (code: Code | MdxJsxFlowElement, idx): MdxJsxFlowElement => {- const file = getFileName(code)- return {- type: 'mdxJsxFlowElement',- name: 'TabPanel',- attributes: [- {- type: 'mdxJsxAttribute',- name: 'id',- value: file || `File ${idx + 1}`,- },- {- type: 'mdxJsxAttribute',- name: 'label',- value: file || `File ${idx + 1}`,- },- ],- children: [code],+ visitParents(+ tree,+ ['mdxJsxFlowElement', 'code'],+ (node: MdxJsxFlowElement | Code, ancestors: Array<Parent>) => {+ if (node.type === 'mdxJsxFlowElement') {+ if (node.name !== '$CodeTabs') {+ return+ } else {+ replaceCodeTabs(node, ancestors)+ // Code blocks inside CodeTabs are handled with CodeTabs, so ignore+ // them here+ return SKIP}+ } else {+ nameCodeBlock(node, ancestors)}+ }+ )+}++function replaceCodeTabs(node: MdxJsxFlowElement, ancestors: Array<Parent>) {+ if (node.children.some((child) => child.type !== 'code' && !isCodeSampleWrapper(child))) {+ throw new Error(+ `CodeTabs must contain only code blocks and code sample wrappers, found:\n\n${JSON.stringify(node.children, null, 2)}`)- const tabsWrapper: MdxJsxFlowElement = {- type: 'mdxJsxFlowElement',- name: 'Tabs',- attributes: [- {- type: 'mdxJsxAttribute',- name: 'listClassNames',- value: 'flex-nowrap overflow-x-auto -mb-6',- },- ],- children: remappedChildren,+ }++ const parent = ancestors[ancestors.length - 1]+ const remappedChildren = node.children.map(+ (code: Code | MdxJsxFlowElement, idx): MdxJsxFlowElement => {+ const file = getFileName(code)+ return {+ type: 'mdxJsxFlowElement',+ name: 'TabPanel',+ attributes: [+ {+ type: 'mdxJsxAttribute',+ name: 'id',+ value: file || `File ${idx + 1}`,+ },+ {+ type: 'mdxJsxAttribute',+ name: 'label',+ value: file || `File ${idx + 1}`,+ },+ ],+ children: [code],+ }}+ )+ const tabsWrapper: MdxJsxFlowElement = {+ type: 'mdxJsxFlowElement',+ name: 'Tabs',+ attributes: [+ {+ type: 'mdxJsxAttribute',+ name: 'listClassNames',+ value: 'flex-nowrap overflow-x-auto -mb-6',+ },+ ],+ children: remappedChildren,+ }++ parent.children.splice(parent.children.indexOf(node), 1, tabsWrapper)+}++function nameCodeBlock(node: Code, ancestors: Array<Parent>) {+ const file = getFileName(node)+ if (!file) return- parent.children.splice(parent.children.indexOf(node), 1, tabsWrapper)- })+ const parent = ancestors[ancestors.length - 1]+ const codeBlockWrapper: MdxJsxFlowElement = {+ type: 'mdxJsxFlowElement',+ name: 'NamedCodeBlock',+ attributes: [+ {+ type: 'mdxJsxAttribute',+ name: 'name',+ value: file,+ },+ ],+ children: [node],+ }+ parent.children.splice(parent.children.indexOf(node), 1, codeBlockWrapper)}function getFileName(node: Code | MdxJsxFlowElement): string | undefined {diff --git a/apps/docs/features/docs/MdxBase.shared.tsx b/apps/docs/features/docs/MdxBase.shared.tsxindex cb4d8473586..3c910626d04 100644--- a/apps/docs/features/docs/MdxBase.shared.tsx+++ b/apps/docs/features/docs/MdxBase.shared.tsx@@ -23,6 +23,7 @@ import { RegionsList } from '~/components/RegionsList'import { SharedData } from '~/components/SharedData'import StepHikeCompact from '~/components/StepHikeCompact'import { CodeSampleDummy, CodeSampleWrapper } from '~/features/directives/CodeSample.client'+import { NamedCodeBlock } from '~/features/directives/CodeTabs.components'import { Accordion, AccordionItem } from '~/features/ui/Accordion'import { CodeBlock } from '~/features/ui/CodeBlock/CodeBlock'import InfoTooltip from '~/features/ui/InfoTooltip'@@ -51,6 +52,7 @@ const components = {Image: (props: any) => <Image fill alt="" className="object-contain" {...props} />,JwtGenerator,Link,+ NamedCodeBlock,NavData,ProjectConfigVariables,RealtimeLimitsEstimator,diff --git a/apps/docs/features/docs/Reference.sections.tsx b/apps/docs/features/docs/Reference.sections.tsxindex 4847b25e3d4..cae66a09f49 100644--- a/apps/docs/features/docs/Reference.sections.tsx+++ b/apps/docs/features/docs/Reference.sections.tsx@@ -470,7 +470,7 @@ async function FunctionSection({{fn.examples.map((example) => (<TabsContent_Shadcn_ key={example.id} value={example.id}><MDXRemoteRefs source={example.code} />- <div className="flex flex-col gap-2">+ <div className="flex flex-col gap-2 mt-2">{!!example.data?.sql && (<CollapsibleDetails title="Data source" content={example.data.sql} />)}diff --git a/apps/docs/features/ui/CodeBlock/CodeBlock.tsx b/apps/docs/features/ui/CodeBlock/CodeBlock.tsxindex b2f99817423..cbbf7d4b272 100644--- a/apps/docs/features/ui/CodeBlock/CodeBlock.tsx+++ b/apps/docs/features/ui/CodeBlock/CodeBlock.tsx@@ -9,14 +9,7 @@ import denoTypes from './types/lib.deno.d.ts.include'const extraFiles: ExtraFiles = { 'deno.d.ts': denoTypes }const twoslasher = createTwoslasher({ extraFiles })-const TWOSLASHABLE_LANGS: ReadonlyArray<string> = [- 'js',- 'ts',- 'jsx',- 'tsx',- 'javascript',- 'typescript',-]+const TWOSLASHABLE_LANGS: ReadonlyArray<string> = ['js', 'ts', 'javascript', 'typescript']export async function CodeBlock({className,@@ -42,6 +35,10 @@ export async function CodeBlock({code = editedCode} catch (_err) {// Silently ignore, if imports aren't defined type compilation fails+ // Uncomment lines below to debug in dev+ // console.log('\n==========CODE==========\n')+ // console.log(code)+ // console.error(_err.recommendation)}}diff --git a/apps/docs/styles/main.scss b/apps/docs/styles/main.scssindex f8bf24e02d2..1d599b80ffc 100644--- a/apps/docs/styles/main.scss+++ b/apps/docs/styles/main.scss@@ -364,6 +364,6 @@ th code {// Code blocks need margin applied when in content container-.prose :where(.shiki) {+.prose :where(.shiki:not(.shiki-wrapper *), .shiki-wrapper) {margin-block: 2rem;}