Using Hanko with Supabase
This guide showcases how to add new user info, like user ID and email to the Supabase database, when users sign up with Hanko. Jump to Nextjs guide to learn how to add Hanko Auth in your Next App.
We’re using Next.js in this guide, but don’t worry, you can apply the same concepts to other frameworks or languages. We’re working on adding examples with different frameworks, so stay tuned!
Create an account on Supabase
Create an account on Supabase if you haven’t yet.
Create a new project
Once you’ve created an account, you’ll be redirected to the dashboard. Click on ‘New Project’ to create a new project.
Create users table
Now, on the project dashboard, choose ‘Database’ and create a new ‘users’ table. We’ll be using this table to add new user info on signup. In addition to the default ‘id’ column, add ‘user_id’ and ‘email’ columns.
Get URL and service_role key from Supabase and add it to your project
Now in the project dashboard, select ‘Project Settings’ from the left sidebar and then click on ‘API’. Copy the ‘URL’ and ‘service_role’ key and paste them in your .env.local
file.
Install Supabase JavaScript Client
Assuming you’ve already set up Hanko Auth, you’ll need to install supabase to your app.
Set up Supabase Client
Create an API
Next up, you’ll create an api to add new user info to the users table.
Use the API in HankoAuth component
Use the API to add a new user to the ‘users’ table, as soon as user is authenticated and onSessionCreated
is triggered.
Was this page helpful?