Skip to content

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

docs: create section for redirect urls

Kang Ming169bb5c3b883
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index b9e38960b01..9498cbe2ac4 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -449,6 +449,10 @@ export const auth = {
name: 'Overview',
url: '/guides/auth',
},
+ {
+ name: 'Redirect URLs',
+ url: '/guides/auth/concepts/redirect-urls',
+ },
{
name: 'Quickstarts',
items: [
diff --git a/apps/docs/pages/guides/auth.mdx b/apps/docs/pages/guides/auth.mdx
index b827086f831..2a516ff35ea 100644
--- a/apps/docs/pages/guides/auth.mdx
+++ b/apps/docs/pages/guides/auth.mdx
@@ -6,12 +6,10 @@ export const meta = {
id: 'auth',
title: 'Auth',
description: 'Use Supabase to Authenticate and Authorize your users.',
- sidebar_label: 'Overview',
+ subtitle: 'Use Supabase to authenticate and authorize your users.',
video: 'https://www.youtube.com/v/6ow_jW4epf8',
}
-## Overview
-
There are two parts to every Auth system:
- **Authentication:** should this person be allowed in? If yes, who are they?
@@ -64,56 +62,13 @@ You can enable third-party providers with the click of a button by navigating to
### Redirect URLs and wildcards
-When using third-party providers, the [Supabase client library](/docs/reference/javascript/auth-signinwithoauth#sign-in-using-a-third-party-provider-with-redirect) redirects the user to the provider. When the third-party provider successfully authenticates the user, the provider redirects the user to the Supabase Auth callback URL where they are further redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/reference/auth/config#site_url). You can modify the `SITE_URL` or add additional [redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration).
-
-You can use wildcard match patterns to support preview URLs from providers like Netlify and Vercel. See the [full list of supported patterns](https://pkg.go.dev/github.com/gobwas/glob#Compile). Use [this tool](https://www.digitalocean.com/community/tools/glob?comments=true&glob=http%3A%2F%2Flocalhost%3A3000%2F%2A%2A&matches=false&tests=http%3A%2F%2Flocalhost%3A3000&tests=http%3A%2F%2Flocalhost%3A3000%2F&tests=http%3A%2F%2Flocalhost%3A3000%2F%3Ftest%3Dtest&tests=http%3A%2F%2Flocalhost%3A3000%2Ftest-test%3Ftest%3Dtest&tests=http%3A%2F%2Flocalhost%3A3000%2Ftest%2Ftest%3Ftest%3Dtest) to test your patterns.
-
-<Admonition type="note" label="Recommendation">
-
-While the "globstar" (`**`) is useful for local development and preview URLs, we recommend setting the exact redirect URL path for your site URL in production.
-
-</Admonition>
-
-#### Netlify preview URLs
-
-For deployments with Netlify, set the `SITE_URL` to your official site URL. Add the following additional redirect URLs for local development and deployment previews:
-
-- `http://localhost:3000/**`
-- `https://**--my_org.netlify.app/**`
+We've moved the guide for setting up redirect URLs [here](/docs/guides/auth/concepts/redirect-urls).
-#### Vercel preview URLs
-
-For deployments with Vercel, set the `SITE_URL` to your official site URL. Add the following additional redirect URLs for local development and deployment previews:
-
-- `http://localhost:3000/**`
-- `https://*-username.vercel.app/**`
-
-Vercel provides an environment variable for the URL of the deployment called `NEXT_PUBLIC_VERCEL_URL`. See the [Vercel docs](https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables) for more details. You can use this variable to dynamically redirect depending on the environment. You should also set the value of the environment variable called NEXT_PUBLIC_SITE_URL, this should be set to your site URL in production environment to ensure that redirects function correctly.
-
-```js
-const getURL = () => {
- let url =
- process?.env?.NEXT_PUBLIC_SITE_URL ?? // Set this to your site URL in production env.
- process?.env?.NEXT_PUBLIC_VERCEL_URL ?? // Automatically set by Vercel.
- 'http://localhost:3000/'
- // Make sure to include `https://` when not localhost.
- url = url.includes('http') ? url : `https://${url}`
- // Make sure to include a trailing `/`.
- url = url.charAt(url.length - 1) === '/' ? url : `${url}/`
- return url
-}
-
-const { data, error } = await supabase.auth.signInWithOAuth({
- provider: 'github',
- options: {
- redirectTo: getURL(),
- },
-})
-```
+#### [Netlify preview URLs](/docs/guides/auth/concepts/redirect-urls#netlify-preview-urls)
-#### Mobile deep linking URIs
+#### [Vercel preview URLs](/docs/guides/auth/concepts/redirect-urls#vercel-preview-urls)
-For mobile applications you can use deep linking URIs. For example for your `SITE_URL` you can specify something like `com.supabase://login-callback/` and for additional redirect URLs something like `com.supabase.staging://login-callback/` if needed.
+#### [Mobile deep linking URIs](/docs/guides/auth/concepts/redirect-urls#mobile-deep-linking-uris)
## Authorization
diff --git a/apps/docs/pages/guides/auth/concepts/redirect-urls.mdx b/apps/docs/pages/guides/auth/concepts/redirect-urls.mdx
new file mode 100644
index 00000000000..371df16ed15
--- /dev/null
+++ b/apps/docs/pages/guides/auth/concepts/redirect-urls.mdx
@@ -0,0 +1,87 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'redirect-urls',
+ title: 'Redirect URLs',
+ description: 'Set up redirect urls with Supabase Auth.',
+ subtitle: 'Set up redirect urls with Supabase Auth.',
+}
+
+## Overview
+
+When using [passwordless sign-ins](/docs/reference/javascript/auth-signinwithotp) or [third-party providers](/docs/reference/javascript/auth-signinwithoauth#sign-in-using-a-third-party-provider-with-redirect), the Supabase client library methods provide a `redirectTo` parameter to specify where to redirect the user to after authentication. By default, the user will be redirected to the [`SITE_URL`](/docs/reference/auth/config#site_url) but you can modify the `SITE_URL` or add additional redirect URLs to the [allow list](https://supabase.com/dashboard/project/_/auth/url-configuration). Once you've added necessary URLs to the allow list, you can specify the URL you want the user to be redirected to in the `redirectTo` parameter.
+
+## Use wildcards in redirect URLs
+
+Supabase allows you to specify wildcards when adding redirect URLs to the [allow list](https://supabase.com/dashboard/project/_/auth/url-configuration). You can use wildcard match patterns to support preview URLs from providers like Netlify and Vercel.
+
+| Wildcard | Description |
+| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
+| `*` | matches any sequence of non-separator characters |
+| `**` | matches any sequence of characters |
+| `?` | matches any single non-separator character |
+| `c` | matches character c (c != `*`, `**`, `?`, `\`, `[`, `{`, `}`) |
+| `\c` | matches character c |
+| `[!{ character-range }]` | matches any sequence of characters not in the `{ character-range }`. For example, `[!a-z]` will not match any characters ranging from a-z. |
+
+The separator characters in a URL are defined as `.` and `/`. Use [this tool](https://www.digitalocean.com/community/tools/glob?comments=true&glob=http%3A%2F%2Flocalhost%3A3000%2F%2A%2A&matches=false&tests=http%3A%2F%2Flocalhost%3A3000&tests=http%3A%2F%2Flocalhost%3A3000%2F&tests=http%3A%2F%2Flocalhost%3A3000%2F%3Ftest%3Dtest&tests=http%3A%2F%2Flocalhost%3A3000%2Ftest-test%3Ftest%3Dtest&tests=http%3A%2F%2Flocalhost%3A3000%2Ftest%2Ftest%3Ftest%3Dtest) to test your patterns.
+
+<Admonition type="note" label="Recommendation">
+
+While the "globstar" (`**`) is useful for local development and preview URLs, we recommend setting the exact redirect URL path for your site URL in production.
+
+</Admonition>
+
+### Redirect URL examples with wildcards
+
+| Redirect URL | Description |
+| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `http://localhost:3000/*` | matches `http://localhost:3000/foo`, `http://localhost:3000/bar` but not `http://localhost:3000/foo/bar` or `http://localhost:3000/foo/` (note the trailing slash) |
+| `http://localhost:3000/**` | matches `http://localhost:3000/foo`, `http://localhost:3000/bar` and `http://localhost:3000/foo/bar` |
+| `http://localhost:3000/?` | matches `http://localhost:3000/a` but not `http://localhost:3000/foo` |
+| `http://localhost:3000/[!a-z]` | matches `http://localhost:3000/1` but not `http://localhost:3000/a` |
+
+## Netlify preview URLs
+
+For deployments with Netlify, set the `SITE_URL` to your official site URL. Add the following additional redirect URLs for local development and deployment previews:
+
+- `http://localhost:3000/**`
+- `https://**--my_org.netlify.app/**`
+
+## Vercel preview URLs
+
+For deployments with Vercel, set the `SITE_URL` to your official site URL. Add the following additional redirect URLs for local development and deployment previews:
+
+- `http://localhost:3000/**`
+- `https://*-username.vercel.app/**`
+
+Vercel provides an environment variable for the URL of the deployment called `NEXT_PUBLIC_VERCEL_URL`. See the [Vercel docs](https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables) for more details. You can use this variable to dynamically redirect depending on the environment. You should also set the value of the environment variable called NEXT_PUBLIC_SITE_URL, this should be set to your site URL in production environment to ensure that redirects function correctly.
+
+```js
+const getURL = () => {
+ let url =
+ process?.env?.NEXT_PUBLIC_SITE_URL ?? // Set this to your site URL in production env.
+ process?.env?.NEXT_PUBLIC_VERCEL_URL ?? // Automatically set by Vercel.
+ 'http://localhost:3000/'
+ // Make sure to include `https://` when not localhost.
+ url = url.includes('http') ? url : `https://${url}`
+ // Make sure to include a trailing `/`.
+ url = url.charAt(url.length - 1) === '/' ? url : `${url}/`
+ return url
+}
+
+const { data, error } = await supabase.auth.signInWithOAuth({
+ provider: 'github',
+ options: {
+ redirectTo: getURL(),
+ },
+})
+```
+
+## Mobile deep linking URIs
+
+For mobile applications you can use deep linking URIs. For example, for your `SITE_URL` you can specify something like `com.supabase://login-callback/` and for additional redirect URLs something like `com.supabase.staging://login-callback/` if needed.
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page