Skip to content

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

fix: update code examples for ssr on social login guides (#27906)

Charis3df871be4b35
diff --git a/apps/docs/components/MDX/create_client_snippet.mdx b/apps/docs/components/MDX/create_client_snippet.mdx
new file mode 100644
index 00000000000..4e2fe443c23
--- /dev/null
+++ b/apps/docs/components/MDX/create_client_snippet.mdx
@@ -0,0 +1,7 @@
+<Admonition type="tip">
+
+Make sure you're using the right `supabase` client in the following code.
+
+If you're not using Server-Side Rendering or cookie-based Auth, you can directly use the `createClient` from `@supabase/supabase-js`. If you're using Server-Side Rendering, see the [Server-Side Auth guide](/docs/guides/auth/server-side/creating-a-client) for instructions on creating your Supabase client.
+
+</Admonition>
diff --git a/apps/docs/components/MDX/oauth_pkce_flow.mdx b/apps/docs/components/MDX/oauth_pkce_flow.mdx
index 53c03e47c44..3ac206b2540 100644
--- a/apps/docs/components/MDX/oauth_pkce_flow.mdx
+++ b/apps/docs/components/MDX/oauth_pkce_flow.mdx
@@ -57,9 +57,9 @@ 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
-import { cookies } from 'next/headers'
import { NextResponse } from 'next/server'
-import { type CookieOptions, createServerClient } from '@supabase/ssr'
+// The client you created from the Server-Side Auth instructions
+import { createClient } from '@/utils/supabase/server'
export async function GET(request: Request) {
const { searchParams, origin } = new URL(request.url)
@@ -68,24 +68,7 @@ export async function GET(request: Request) {
const next = searchParams.get('next') ?? '/'
if (code) {
- const cookieStore = cookies()
- const supabase = createServerClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
- {
- cookies: {
- get(name: string) {
- return cookieStore.get(name)?.value
- },
- set(name: string, value: string, options: CookieOptions) {
- cookieStore.set({ name, value, ...options })
- },
- remove(name: string, options: CookieOptions) {
- cookieStore.delete({ name, ...options })
- },
- },
- }
- )
+ const supabase = createClient()
const { error } = await supabase.auth.exchangeCodeForSession(code)
if (!error) {
return NextResponse.redirect(`${origin}${next}`)
@@ -132,7 +115,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
-import { createServerClient } from '@supabase/ssr'
+import { createServerClient, parseCookieHeader } from '@supabase/ssr'
import { type APIRoute } from 'astro'
export const GET: APIRoute = async ({ request, cookies, redirect }) => {
@@ -146,14 +129,13 @@ export const GET: APIRoute = async ({ request, cookies, redirect }) => {
import.meta.env.PUBLIC_SUPABASE_ANON_KEY,
{
cookies: {
- get(key) {
- return cookies.get(key)?.value
+ getAll() {
+ return parseCookieHeader(Astro.request.headers.get('Cookie') ?? '')
},
- set(key, value, options) {
- cookies.set(key, value, options)
- },
- remove(key, options) {
- cookies.delete(key, options)
+ setAll(cookiesToSet) {
+ cookiesToSet.forEach(({ name, value, options }) =>
+ Astro.cookies.set(name, value, options)
+ )
},
},
}
@@ -179,7 +161,7 @@ Create a new file at `app/routes/auth.callback.tsx` and populate with the follow
```ts app/routes/auth.callback.tsx
import { redirect, type LoaderFunctionArgs } from '@remix-run/node'
-import { createServerClient, parse, serialize } from '@supabase/ssr'
+import { createServerClient, parseCookieHeader, serializeCookieHeader } from '@supabase/ssr'
export async function loader({ request }: LoaderFunctionArgs) {
const requestUrl = new URL(request.url)
@@ -191,14 +173,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
const cookies = parse(request.headers.get('Cookie') ?? '')
const supabase = createServerClient(process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!, {
cookies: {
- get(key) {
- return cookies[key]
- },
- set(key, value, options) {
- headers.append('Set-Cookie', serialize(key, value, options))
+ getAll() {
+ return parseCookieHeader(request.headers.get('Cookie') ?? '')
},
- remove(key, options) {
- headers.append('Set-Cookie', serialize(key, '', options))
+ setAll(cookiesToSet) {
+ cookiesToSet.forEach(({ name, value, options }) =>
+ headers.append('Set-Cookie', serializeCookieHeader(name, value, options))
+ )
},
},
})
@@ -227,7 +208,20 @@ app.get("/auth/callback", async function (req, res) {
const next = req.query.next ?? "/"
if (code) {
- const supabase = createClient({ req, res })
+ const supabase = createServerClient(
+ process.env.SUPABASE_URL,
+ process.env.SUPABASE_ANON_KEY, {
+ cookies: {
+ getAll() {
+ return parseCookieHeader(context.req.headers.cookie ?? '')
+ },
+ setAll(cookiesToSet) {
+ cookiesToSet.forEach(({ name, value, options }) =>
+ context.res.appendHeader('Set-Cookie', serializeCookieHeader(name, value, options))
+ )
+ },
+ },
+ })
await supabase.auth.exchangeCodeForSession(code)
}
diff --git a/apps/docs/components/MDX/partials.tsx b/apps/docs/components/MDX/partials.tsx
index 982846bd40d..7b10795e752 100644
--- a/apps/docs/components/MDX/partials.tsx
+++ b/apps/docs/components/MDX/partials.tsx
@@ -1,6 +1,7 @@
'use client'
import AuthRateLimits from './auth_rate_limits.mdx'
+import CreateClientSnippet from './create_client_snippet.mdx'
import DatabaseSetup from './database_setup.mdx'
import GetSessionWarning from './get_session_warning.mdx'
import HuggingFaceDeployment from './ai/quickstart_hf_deployment.mdx'
@@ -14,6 +15,7 @@ import SocialProviderSetup from './social_provider_setup.mdx'
export {
AuthRateLimits,
+ CreateClientSnippet,
DatabaseSetup,
GetSessionWarning,
HuggingFaceDeployment,
diff --git a/apps/docs/content/guides/auth/server-side/creating-a-client.mdx b/apps/docs/content/guides/auth/server-side/creating-a-client.mdx
index ed192bbdf0f..30d2511567c 100644
--- a/apps/docs/content/guides/auth/server-side/creating-a-client.mdx
+++ b/apps/docs/content/guides/auth/server-side/creating-a-client.mdx
@@ -1,25 +1,53 @@
---
title: 'Creating a Supabase client for SSR'
-description: 'Configure Supabase client to use Cookies'
-sidebar_label: 'Creating a client'
+subtitle: 'Configure your Supabase client to use cookies'
---
-### Install Supabase packages
+To use Server-Side Rendering (SSR) with Supabase, you need to configure your Supabase client to use cookies. The `@supabase/ssr` package helps you do this for JavaScript/TypeScript applications.
-The `ssr` package configures Supabase to use Cookies, which is required for server-side languages and frameworks.
+## Install
+
+Install the `@supabase/ssr` and `@supabase/supabase-js` packages:
+
+<Tabs size="small" type="underlined" queryGroup="package-manager" defaultActiveId="npm">
+
+<TabPanel id="npm" label="npm">
```bash
npm install @supabase/ssr @supabase/supabase-js
```
-### Set environment variables
+</TabPanel>
+
+<TabPanel id="yarn" label="yarn">
+
+```bash
+yarn add @supabase/ssr @supabase/supabase-js
+```
+
+</TabPanel>
+
+<TabPanel id="pnpm" label="pnpm">
+
+```bash
+pnpm add @supabase/ssr @supabase/supabase-js
+```
+
+</TabPanel>
+
+</Tabs>
+
+## Set environment variables
+
+In your environment variables file, set your Supabase URL and Supabase Anon Key:
+
+<ProjectConfigVariables variable="url" />
+<ProjectConfigVariables variable="anonKey" />
<Tabs scrollable size="small" type="underlined" defaultActiveId="nextjs" queryGroup="framework">
<TabPanel id="nextjs" label="Next.js">
-Create a `.env.local` file in your project root directory. You can get your `SUPABASE_URL` and `SUPABASE_ANON_KEY` from inside [your Supabase project's dashboard](https://supabase.com/dashboard/project/_/settings/api).
-
```bash .env.local
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
@@ -28,8 +56,6 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
</TabPanel>
<TabPanel id="sveltekit" label="SvelteKit">
-Create a `.env.local` file in your project root directory. You can get your `SUPABASE_URL` and `SUPABASE_ANON_KEY` from inside [your Supabase project's dashboard](https://supabase.com/dashboard/project/_/settings/api).
-
```bash .env.local
PUBLIC_SUPABASE_URL=your_supabase_project_url
PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
@@ -38,8 +64,6 @@ PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
</TabPanel>
<TabPanel id="astro" label="Astro">
-Create a `.env` file in your project root directory. You can get your `SUPABASE_URL` and `SUPABASE_ANON_KEY` from inside [your Supabase project's dashboard](https://supabase.com/dashboard/project/_/settings/api).
-
```bash .env
PUBLIC_SUPABASE_URL=your_supabase_project_url
PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
@@ -48,8 +72,6 @@ PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
</TabPanel>
<TabPanel id="remix" label="Remix">
-Create a `.env` file in your project root directory. You can get your `SUPABASE_URL` and `SUPABASE_ANON_KEY` from inside [your Supabase project's dashboard](https://supabase.com/dashboard/project/_/settings/api).
-
```bash .env
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
@@ -58,32 +80,55 @@ SUPABASE_ANON_KEY=your_supabase_anon_key
</TabPanel>
<TabPanel id="express" label="Express">
-Create a `.env` file in your project root directory. You can get your `SUPABASE_URL` and `SUPABASE_ANON_KEY` from inside [your Supabase project's dashboard](https://supabase.com/dashboard/project/_/settings/api).
-
```bash .env
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
```
-Install [dotenv](https://www.npmjs.com/package/dotenv)
+Install [dotenv](https://www.npmjs.com/package/dotenv):
```bash
npm i dotenv
```
-and initialize it
+And initialize it:
-```js app.js
-const express = require("express")
-const dotenv = require("dotenv")
-dotenv.config()
-...
+<Tabs size="small" type="underlined" queryGroup="package-manager" defaultActiveId="npm">
+
+<TabPanel id="npm" label="npm">
+
+```bash
+npm install dotenv
+```
+
+</TabPanel>
+
+<TabPanel id="yarn" label="yarn">
+
+```bash
+yarn add dotenv
```
+</TabPanel>
+
+<TabPanel id="pnpm" label="pnpm">
+
+```bash
+pnpm add dotenv
+```
+
+</TabPanel>
+
+</Tabs>
+
</TabPanel>
</Tabs>
-### Creating a client
+## Create a client
+
+You'll need some one-time setup code to configure your Supabase client to use cookies. Once your utility code is set up, you can use your new `createClient` utility functions to get a properly configured Supabase client.
+
+Use the browser client in code that runs on the browser, and the server client in code that runs on the server.
<Tabs
scrollable
@@ -94,13 +139,7 @@ dotenv.config()
>
<TabPanel id="nextjs" label="Next.js">
-Creating a Supabase client with the `ssr` package automatically configures it to use cookies. This means your user's session is available throughout the entire Next.js stack - client, server, App Router, Pages Router. It just works!
-
-<Admonition type="note">
-
-For the client utility functions, it is recommended to create them in a separate `/utils/supabase` folder. That way, you can import them as `client` into any component or page that needs access to Supabase. For further information, you can look at the [Next.js Auth Guide](/docs/guides/auth/server-side/nextjs).
-
-</Admonition>
+The following code samples are for App Router. For help with Pages Router, see the [Next.js Server-Side Auth guide](/docs/guides/auth/server-side/nextjs?queryGroups=router&router=pages).
<Tabs
scrollable
@@ -109,41 +148,33 @@ For the client utility functions, it is recommended to create them in a separate
defaultActiveId="client-component"
queryGroup="environment"
>
-<TabPanel id="client-component" label="Client Component">
+<TabPanel id="client" label="Client-side">
-```ts page.tsx
-"use client";
+```ts utils/supabase/client.tsx
+'use client'
import { createBrowserClient } from '@supabase/ssr'
-export default function Page () {
- const supabase = createBrowserClient(
+export function createClient() {
+ return createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)
-
- return ...
}
```
</TabPanel>
-<TabPanel id="server-component" label="Server Component">
-
-<Admonition type="note">
-
-Server Components only have read access to cookies. Check the `Middleware` tab for an example of refreshing expired sessions before loading a Server Component route.
+<TabPanel id="server" label="Server-side">
-</Admonition>
-
-```ts page.tsx
+```ts utils/supabase/server.tsx
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
-export default async function Page () {
+export function createClient() {
const cookieStore = cookies()
- const supabase = createServerClient(
+ return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
@@ -151,11 +182,20 @@ export default async function Page () {
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.
+ }
+ },
},
}
)
-
- return ...
}
```
@@ -163,17 +203,35 @@ export default async function Page () {
<TabPanel id="middleware" label="Middleware">
-<Admonition type="note">
+In Next.js, because Server Components cannot set cookies, you'll also need a middleware client to handle cookie refreshes. The middleware should run before every route that needs access to Supabase, or that is protected by Supabase Auth.
-Server Components only have read access to cookies. This `Middleware` example can be used to refresh expired sessions before loading Server Component routes.
+```ts middleware.ts
+import { type NextRequest } from 'next/server'
+import { updateSession } from '@/utils/supabase/middleware'
-</Admonition>
+export async function middleware(request: NextRequest) {
+ return await updateSession(request)
+}
-```ts middleware.ts
-import { createServerClient, type CookieOptions } from '@supabase/ssr'
+export const config = {
+ matcher: [
+ /*
+ * Match all request paths except for the ones starting with:
+ * - _next/static (static files)
+ * - _next/image (image optimization files)
+ * - favicon.ico (favicon file)
+ * Feel free to modify this pattern to include more paths.
+ */
+ '/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
+ ],
+}
+```
+
+```ts utils/supabase/middlware.ts
+import { createServerClient } from '@supabase/ssr'
import { NextResponse, type NextRequest } from 'next/server'
-export async function middleware(request: NextRequest) {
+export async function updateSession(request: NextRequest) {
let supabaseResponse = NextResponse.next({
request,
})
@@ -187,7 +245,7 @@ export async function middleware(request: NextRequest) {
return request.cookies.getAll()
},
setAll(cookiesToSet) {
- cookiesToSet.forEach(({ name, value }) => request.cookies.set(name, value))
+ cookiesToSet.forEach(({ name, value, options }) => request.cookies.set(name, value))
supabaseResponse = NextResponse.next({
request,
})
@@ -233,188 +291,6 @@ export async function middleware(request: NextRequest) {
return supabaseResponse
}
-
-export const config = {
- matcher: [
- /*
- * Match all request paths except for the ones starting with:
- * - _next/static (static files)
- * - _next/image (image optimization files)
- * - favicon.ico (favicon file)
- * Feel free to modify this pattern to include more paths.
- */
- '/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
- ],
-}
-```
-
-</TabPanel>
-
-<TabPanel id="route-handler" label="Route Handler">
-
-```ts route.ts
-import { createServerClient, type CookieOptions } from '@supabase/ssr'
-import { cookies } from 'next/headers'
-
-export async function POST(request: Request) {
- const cookieStore = cookies()
-
- const supabase = createServerClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
- {
- cookies: {
- getAll() {
- return cookieStore.getAll()
- },
- setAll(cookiesToSet) {
- cookiesToSet.forEach(({ name, value, options }) =>
- cookieStore.set(name, value, options))
- },
- },
- }
- )
-
- return ...
-}
-```
-
-</TabPanel>
-
-<TabPanel id="server-action" label="Server Action">
-
-```ts page.tsx
-import { createServerClient, type CookieOptions } from '@supabase/ssr'
-import { cookies } from 'next/headers'
-
-export default async function Page () {
- const serverAction = async () => {
- 'use server'
-
- const cookieStore = cookies()
-
- const supabase = createServerClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
- {
- cookies: {
- getAll() {
- return cookieStore.getAll()
- },
- setAll(cookiesToSet) {
- cookiesToSet.forEach(({ name, value, options }) =>
- cookieStore.set(name, value, options))
- },
- },
- }
- )
- }
-
- return ...
-}
-```
-
-</TabPanel>
-
-<TabPanel id="get-server-side-props" label="getServerSideProps">
-
-```ts index.tsx
-import { type GetServerSidePropsContext } from 'next'
-import { createServerClient, serializeCookieHeader } from '@supabase/ssr'
-
-export const getServerSideProps = async ({ req, res }: GetServerSidePropsContext) => {
- const supabase = createServerClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
- {
- cookies: {
- getAll() {
- return Object.keys(req.cookies)
- .map((name) => ({ name, value: req.cookies[name] }))
- },
- setAll(cookiesToSet) {
- res.setHeader('Set-Cookie',
- cookiesToSet.map(({ name, value, options }) =>
- serializeCookieHeader(name, value, options)))
- },
- },
- }
- )
-
- return {...}
-}
-```
-
-</TabPanel>
-
-<TabPanel id="get-static-props" label="getStaticProps">
-
-The `getStaticProps` function gets executed at build time, rather than per request. At build time,
-there is no user, session or cookies. Therefore, we can use the standard `createClient` function
-from `supabase-js`.
-
-```ts page.tsx
-import { createClient } from '@supabase/supabase-js'
-
-export const getStaticProps = async () => {
- const supabase = createClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
- )
-
- return {...}
-}
-```
-
-</TabPanel>
-
-<TabPanel id="api-route" label="API Route">
-
-```ts index.tsx
-import { createServerClient, serializeCookieHeader } from "@supabase/ssr"
-import { type NextApiRequest, type NextApiResponse } from "next"
-
-export default async function handler(
- req: NextApiRequest,
- res: NextApiResponse
-) {
- const supabase = createServerClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
- {
- cookies: {
- getAll() {
- return Object.keys(req.cookies)
- .map((name) => ({ name, value: req.cookies[name] }))
- },
- setAll(cookiesToSet) {
- res.setHeader('Set-Cookie',
- cookiesToSet.map(({ name, value, options }) =>
- serializeCookieHeader(name, value, options)))
- },
- },
- }
- )
-
- res.send(...)
-}
-```
-
-</TabPanel>
-
-<TabPanel id="pages-component" label="Pages Component">
-
-```ts index.tsx
-import { createBrowserClient } from "@supabase/ssr"
-
-export default function Index () {
- const supabase = createBrowserClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL!,
- process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
- )
-
- return ...
-}
```
</TabPanel>
@@ -423,8 +299,6 @@ export default function Index () {
</TabPanel>
<TabPanel id="sveltekit" label="SvelteKit">
-Creating a Supabase client with the `ssr` package automatically configures it to use Cookies. This means your user's session is available throughout the entire SvelteKit stack - page, layout, server, hooks.
-
<Tabs
scrollable
size="small"
@@ -434,12 +308,6 @@ Creating a Supabase client with the `ssr` package automatically configures it to
>
<TabPanel id="hooks" label="Hooks">
-<Admonition type="note">
-
-API routes, server layout load and form actions can now access the supabase client from the `event` object due to this hook.
-
-</Admonition>
-
```ts hooks.server.ts
import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public'
import { createServerClient } from '@supabase/ssr'
@@ -502,12 +370,8 @@ export const handle: Handle = async ({ event, resolve }) => {
<TabPanel id="layout" label="Root Layout Load">
-<Admonition type="note">
-
Page components can get access to the supabase client from the `data` object due to this load function.
-</Admonition>
-
```ts +layout.ts
import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public'
import type { LayoutLoad } from './$types'
@@ -566,52 +430,6 @@ export const load: LayoutServerLoad = async ({ locals: { safeGetSession }, cooki
</TabPanel>
-<TabPanel id="page-component" label="Page Component">
-
-```svelte +page.svelte
-<script>
- export let data
- let { supabase } = data
- $: ({ supabase } = data)
-
- ...
-</script>
-
-....
-```
-
-</TabPanel>
-
-<TabPanel id="api-route" label="API route">
-
-```ts +server.ts
-import { redirect } from '@sveltejs/kit';
-
-export const GET = async (event) => {
- const { url, locals: { supabase } } = event
- ...
-}
-```
-
-</TabPanel>
-
-<TabPanel id="form-actions" label="Form actions">
-
-```ts +page.server.ts
-import type { Actions } from './$types'
-
-export const actions: Actions = {
- default: async (event) => {
- const { request, url, locals: { supabase } } = event
- const formData = await request.formData()
- const email = formData.get('email') as string
- const password = formData.get('password') as string
- ...
- }
-}
-```
-
-</TabPanel>
</Tabs>
</TabPanel>
diff --git a/apps/docs/content/guides/auth/social-login/auth-apple.mdx b/apps/docs/content/guides/auth/social-login/auth-apple.mdx
index 2b6f0f20f2b..e86bd8b20dd 100644
--- a/apps/docs/content/guides/auth/social-login/auth-apple.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-apple.mdx
@@ -37,6 +37,8 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,
Behind the scenes, Supabase Auth uses the [REST APIs](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api) provided by Apple.
+ <CreateClientSnippet />
+
To initiate sign in, you can use the `signInWithOAuth()` method from the Supabase JavaScript library:
```ts
diff --git a/apps/docs/content/guides/auth/social-login/auth-azure.mdx b/apps/docs/content/guides/auth/social-login/auth-azure.mdx
index 7ec495d96de..11a1fe9997e 100644
--- a/apps/docs/content/guides/auth/social-login/auth-azure.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-azure.mdx
@@ -124,6 +124,8 @@ Supabase Auth requires that Azure returns a valid email address. Therefore you m
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `azure` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx b/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx
index c22cd02fd8f..d885dfd763f 100644
--- a/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-bitbucket.mdx
@@ -55,6 +55,8 @@ Setting up Bitbucket logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `bitbucket` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-discord.mdx b/apps/docs/content/guides/auth/social-login/auth-discord.mdx
index 4f3be5a850a..285189ec891 100644
--- a/apps/docs/content/guides/auth/social-login/auth-discord.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-discord.mdx
@@ -54,6 +54,8 @@ Setting up Discord logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `discord` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-facebook.mdx b/apps/docs/content/guides/auth/social-login/auth-facebook.mdx
index 0f08e553143..d9dc09a8679 100644
--- a/apps/docs/content/guides/auth/social-login/auth-facebook.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-facebook.mdx
@@ -71,6 +71,8 @@ Under `Build Your App`, click on `Use Cases` screen. From there, do the followin
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `facebook` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-figma.mdx b/apps/docs/content/guides/auth/social-login/auth-figma.mdx
index eeebb78f10c..17bcf0a375f 100644
--- a/apps/docs/content/guides/auth/social-login/auth-figma.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-figma.mdx
@@ -55,6 +55,8 @@ Setting up Figma logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `figma` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-github.mdx b/apps/docs/content/guides/auth/social-login/auth-github.mdx
index 369c5cf56c2..64126a79fed 100644
--- a/apps/docs/content/guides/auth/social-login/auth-github.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-github.mdx
@@ -65,6 +65,8 @@ Copy your new OAuth credentials
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `github` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx b/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx
index add9691c126..0aa3765cb36 100644
--- a/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-gitlab.mdx
@@ -52,6 +52,8 @@ Setting up GitLab logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `gitlab` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-google.mdx b/apps/docs/content/guides/auth/social-login/auth-google.mdx
index e87a182b3d7..4cea739098d 100644
--- a/apps/docs/content/guides/auth/social-login/auth-google.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-google.mdx
@@ -224,6 +224,8 @@ To use Google's pre-built signin buttons:
To use your own application code for the signin button, call the `signInWithOAuth` method (or the equivalent for your language).
+<CreateClientSnippet />
+
```js
supabase.auth.signInWithOAuth({
provider: 'google',
diff --git a/apps/docs/content/guides/auth/social-login/auth-kakao.mdx b/apps/docs/content/guides/auth/social-login/auth-kakao.mdx
index bc51242ca33..b9972537e4b 100644
--- a/apps/docs/content/guides/auth/social-login/auth-kakao.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-kakao.mdx
@@ -77,6 +77,8 @@ This will serve as the `client_id` when you make API calls to authenticate the u
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `kakao` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx b/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx
index 7ca24478c59..53c8f7d3bb9 100644
--- a/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-keycloak.mdx
@@ -70,6 +70,8 @@ Since Keycloak version 22, the `openid` scope must be passed. Add this to the [`
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `keycloak` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx b/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx
index ad4e6369ad5..6df1e65cf47 100644
--- a/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-linkedin.mdx
@@ -63,6 +63,8 @@ Ensure that the appropriate scopes have been added under OAuth 2.0 Scopes at the
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `linkedin_oidc` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-notion.mdx b/apps/docs/content/guides/auth/social-login/auth-notion.mdx
index 3636421b25f..28623884fcc 100644
--- a/apps/docs/content/guides/auth/social-login/auth-notion.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-notion.mdx
@@ -55,6 +55,8 @@ Setting up Notion logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `notion` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-slack.mdx b/apps/docs/content/guides/auth/social-login/auth-slack.mdx
index 338ead28965..fe0309e5775 100644
--- a/apps/docs/content/guides/auth/social-login/auth-slack.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-slack.mdx
@@ -73,6 +73,8 @@ Under `Scopes`:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `slack` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-spotify.mdx b/apps/docs/content/guides/auth/social-login/auth-spotify.mdx
index a3255e35aa8..1b7c4e43eba 100644
--- a/apps/docs/content/guides/auth/social-login/auth-spotify.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-spotify.mdx
@@ -67,6 +67,8 @@ The following outlines the steps to sign in using Spotify with Supabase Auth.
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `spotify` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-twitch.mdx b/apps/docs/content/guides/auth/social-login/auth-twitch.mdx
index 6a215f1f524..a22a2d36489 100644
--- a/apps/docs/content/guides/auth/social-login/auth-twitch.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-twitch.mdx
@@ -70,6 +70,8 @@ Setting up Twitch logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `twitch` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-twitter.mdx b/apps/docs/content/guides/auth/social-login/auth-twitter.mdx
index ddc5a3defdc..aa6c8ee885a 100644
--- a/apps/docs/content/guides/auth/social-login/auth-twitter.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-twitter.mdx
@@ -61,6 +61,8 @@ Setting up Twitter logins for your application consists of 3 parts:
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `twitter` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-workos.mdx b/apps/docs/content/guides/auth/social-login/auth-workos.mdx
index 6020d4bfe6d..0f98f201dd1 100644
--- a/apps/docs/content/guides/auth/social-login/auth-workos.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-workos.mdx
@@ -59,6 +59,8 @@ You can pick between any one of the many identity providers that WorkOS supports
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `workos` as the `provider`:
```js
diff --git a/apps/docs/content/guides/auth/social-login/auth-zoom.mdx b/apps/docs/content/guides/auth/social-login/auth-zoom.mdx
index 3990778e35f..01a5ebf181d 100644
--- a/apps/docs/content/guides/auth/social-login/auth-zoom.mdx
+++ b/apps/docs/content/guides/auth/social-login/auth-zoom.mdx
@@ -68,6 +68,8 @@ Under `Scopes`
>
<TabPanel id="js" label="JavaScript">
+<CreateClientSnippet />
+
When your user signs in, call [signInWithOAuth()](/docs/reference/javascript/auth-signinwithoauth) with `zoom` as the `provider`:
```js
diff --git a/apps/docs/features/docs/mdx.shared.tsx b/apps/docs/features/docs/mdx.shared.tsx
index c6eb04ae6fa..bf5216c35e0 100644
--- a/apps/docs/features/docs/mdx.shared.tsx
+++ b/apps/docs/features/docs/mdx.shared.tsx
@@ -14,6 +14,7 @@ import { Extensions } from '~/components/Extensions'
import { JwtGenerator } from '~/components/JwtGenerator'
import {
AuthRateLimits,
+ CreateClientSnippet,
DatabaseSetup,
GetSessionWarning,
HuggingFaceDeployment,
@@ -47,6 +48,7 @@ const components = {
ButtonCard,
CH,
CostWarning,
+ CreateClientSnippet,
DatabaseSetup,
Extensions,
GetSessionWarning,