Email Auth with PKCE flow for SSR
Learn how to configure email authentication in your server-side rendering (SSR) application to work with the PKCE flow.
Setting up SSR client
Check out our guide for creating a client to learn how to install the necessary packages, declare environment variables, and create a Supabase client configured for SSR in your framework.
Create API endpoint for handling token_hash
In order to use the updated email links we will need to setup a endpoint for verifying the token_hash
along with the type
to exchange token_hash
for the user's session
, which is set as a cookie for future requests made to Supabase.
Create a new file at app/auth/confirm/route.ts
and populate with the following:
Update email templates with URL for API endpoint
Let's update the URL in our email templates to point to our new confirmation endpoint for the user to get confirmed.
Confirm signup template
Invite user template
Magic Link template
Change Email Address template
Reset Password template