Skip to content

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

Docs: Email and Magic Link (#3870)

Isaiah Hamilton20c53f0aa74a
diff --git a/web/docs/guides/auth/auth-email.mdx b/web/docs/guides/auth/auth-email.mdx
new file mode 100644
index 00000000000..da0486bbaad
--- /dev/null
+++ b/web/docs/guides/auth/auth-email.mdx
@@ -0,0 +1,133 @@
+---
+id: auth-email
+title: "Login With Email"
+description: Use Supabase to Authenticate and Authorize your users using email.
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+## Overview
+
+Setting up Email logins for your Supabase application.
+
+* Add Email authenticator to your [Supabase Project](https://app.supabase.io)
+* Add the login code to your application - [Javascript](https://github.com/supabase/supabase-js) | [Dart](https://github.com/supabase/supabase-dart)
+
+## Add Email into your Supabase Project
+
+- Go to your [Supabase Project Dashboard](https://app.supabase.io)
+- In the left sidebar, click the `Authentication` icon (near the top)
+- Click `Settings` from the list to go to the `Authentication Settings` page
+- Enter the final (hosted) URL of your app under `Site URL` (this is important)
+- Under `Email Auth` turn `Enable Email Signup` to ON
+- Click `Save`
+
+### Add login code to your client app
+
+The JavaScript client code is documented here: [Supabase OAuth Client Code](/docs/reference/javascript/auth-signin#sign-in-using-third-party-providers)
+
+<Tabs
+ defaultValue="js"
+ groupId="guides/auth"
+ values={[{ label: 'JavaScript', value: 'js' }, { label: 'Dart', value: 'dart' }]}
+>
+
+<TabItem value="js">
+
+```js
+const { user, error } = await supabase.auth.signIn({
+ email: '[email protected]',
+ password: 'example-password'
+})
+```
+
+</TabItem>
+
+<TabItem value="dart">
+
+```dart
+final res = await supabase.auth.signIn(
+ email: '[email protected]',
+ password: 'example-password'
+);
+
+final user = res.data?.user;
+final error = res.error;
+```
+
+</TabItem>
+
+</Tabs>
+
+Add this function which you can call from a button, link, or UI element.
+
+<Tabs
+ defaultValue="js"
+ groupId="guides/auth"
+ values={[{ label: 'JavaScript', value: 'js' }, { label: 'Dart', value: 'dart' }]}
+>
+
+<TabItem value="js">
+
+```js
+async function signInWithEmail() {
+ const { user, error } = await supabase.auth.signIn({
+ email: '[email protected]',
+ password: 'example-password'
+ });
+}
+```
+
+</TabItem>
+
+<TabItem value="dart">
+
+```dart
+function SignInWithEmail() {
+ await supabase.auth.signIn(
+ email: '[email protected]',
+ password: 'example-password'
+ );
+}
+```
+
+</TabItem>
+
+</Tabs>
+
+To log out:
+
+<Tabs
+ defaultValue="js"
+ groupId="guides/auth"
+ values={[{ label: 'JavaScript', value: 'js' }, { label: 'Dart', value: 'dart' }]}
+>
+
+<TabItem value="js">
+
+```js
+async function signOut() {
+ const { error } = await supabase.auth.signOut();
+}
+```
+
+</TabItem>
+
+<TabItem value="dart">
+
+```dart
+function SignOut() {
+ await supabase.auth.signOut();
+}
+```
+
+</TabItem>
+
+</Tabs>
+
+## Resources
+
+* [Supabase Account - Free Tier OK](https://supabase.io)
+* [Supabase JS Client](https://github.com/supabase/supabase-js)
+* [Supabase Dart Client](https://github.com/supabase/supabase-dart)
\ No newline at end of file
diff --git a/web/docs/guides/auth/auth-magic-link.mdx b/web/docs/guides/auth/auth-magic-link.mdx
new file mode 100644
index 00000000000..cbd4027e2a2
--- /dev/null
+++ b/web/docs/guides/auth/auth-magic-link.mdx
@@ -0,0 +1,131 @@
+---
+id: auth-magic-link
+title: "Login With Magic Link"
+description: Use Supabase to Authenticate and Authorize your users using Magic Link.
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+By default, if no password is provided, the user will be sent a "magic link" to their email address, which they can click to open your application with a valid session. By default, a given user can only request a Magic Link once every 60 seconds.
+
+## Overview
+
+Setting up Magic Link logins for your Supabase application.
+
+* Add Magic Link authenticator to your [Supabase Project](https://app.supabase.io)
+* Add the login code to your application - [Javascript](https://github.com/supabase/supabase-js) | [Dart](https://github.com/supabase/supabase-dart)
+
+## Add Magic Link into your Supabase Project
+
+- Go to your [Supabase Project Dashboard](https://app.supabase.io)
+- In the left sidebar, click the `Authentication` icon (near the top)
+- Click `Settings` from the list to go to the `Authentication Settings` page
+- Enter the final (hosted) URL of your app under `Site URL` (this is important)
+- Under `Email Auth` turn `Enable Email Signup` to ON
+- Click `Save`
+
+### Add login code to your client app
+
+The JavaScript client code is documented here: [Supabase OAuth Client Code](/docs/reference/javascript/auth-signin#sign-in-using-third-party-providers)
+
+<Tabs
+ defaultValue="js"
+ groupId="guides/auth"
+ values={[{ label: 'JavaScript', value: 'js' }, { label: 'Dart', value: 'dart' }]}
+>
+
+<TabItem value="js">
+
+```js
+const { user, error } = await supabase.auth.signIn({
+})
+```
+
+</TabItem>
+
+<TabItem value="dart">
+
+```dart
+final res = await supabase.auth.signIn(
+);
+
+final user = res.data?.user;
+final error = res.error;
+```
+
+</TabItem>
+
+</Tabs>
+
+Add this function which you can call from a button, link, or UI element.
+
+<Tabs
+ defaultValue="js"
+ groupId="guides/auth"
+ values={[{ label: 'JavaScript', value: 'js' }, { label: 'Dart', value: 'dart' }]}
+>
+
+<TabItem value="js">
+
+```js
+async function signInWithEmail() {
+ const { user, error } = await supabase.auth.signIn({
+ });
+}
+```
+
+</TabItem>
+
+<TabItem value="dart">
+
+```dart
+function SignInWithEmail() {
+ await supabase.auth.signIn(
+ );
+}
+```
+
+</TabItem>
+
+</Tabs>
+
+To log out:
+
+<Tabs
+ defaultValue="js"
+ groupId="guides/auth"
+ values={[{ label: 'JavaScript', value: 'js' }, { label: 'Dart', value: 'dart' }]}
+>
+
+<TabItem value="js">
+
+```js
+async function signOut() {
+ const { error } = await supabase.auth.signOut();
+}
+```
+
+</TabItem>
+
+<TabItem value="dart">
+
+```dart
+function SignOut() {
+ await supabase.auth.signOut();
+}
+```
+
+</TabItem>
+
+</Tabs>
+
+## Resources
+
+* [Supabase Account - Free Tier OK](https://supabase.io)
+* [Supabase JS Client](https://github.com/supabase/supabase-js)
+* [Supabase Dart Client](https://github.com/supabase/supabase-dart)
\ No newline at end of file
diff --git a/web/sidebars.js b/web/sidebars.js
index 989216efa68..d94dccfc96e 100755
--- a/web/sidebars.js
+++ b/web/sidebars.js
@@ -145,6 +145,8 @@ module.exports = {
label: 'Authentication',
collapsed: true,
items: [
+ 'guides/auth/auth-email',
+ 'guides/auth/auth-magic-link',
'guides/auth/auth-apple',
'guides/auth/auth-bitbucket',
'guides/auth/auth-discord',