Skip to content

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

[Fix #27119] Update PKCE example code on with-nextjs example (#27184)

Áom | Siriwat J5d2920d028fd
diff --git a/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx b/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx
index b9eb21ae17b..a6ccd22db27 100644
--- a/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx
+++ b/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx
@@ -663,11 +663,11 @@ When you enter your email and password, you will receive an email with the title
Upon sign up, an email will be sent to the user with a unique hash code. This key can then be sent back to the application for verification, thus authenticating the user. The method is referred to as Proof Key for Code Exchange (PKCE). As we are employing PKCE in our authentication flow, it is necessary to create a route handler responsible for exchanging the code for a session.
-In the following code snippet, we perform the following steps:
+Before we proceed, let's change the email template to support sending a PKCE code:
-- Retrieve the code sent back from the Supabase Auth server using the `token_hash` query parameter.
-- Exchange this code for a session, which we store in our chosen storage mechanism (in this case, cookies).
-- Finally, we redirect the user to the `account` page.
+- Go to the [Auth templates](/dashboard/project/_/auth/templates) page in your dashboard.
+- Select `Confirm signup` template.
+- Change `{{ .ConfirmationURL }}` to `{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=signup`.
<Admonition type="tip">
@@ -675,6 +675,12 @@ Did you know? You could also customize emails sent out to new users, including t
</Admonition>
+In the following code snippet, we perform the following steps:
+
+- Retrieve the code sent back from the Supabase Auth server using the `token_hash` query parameter.
+- Exchange this code for a session, which we store in our chosen storage mechanism (in this case, cookies).
+- Finally, we redirect the user to the `account` page.
+
<Tabs
scrollable
size="small"