Follow this guide to get Supabase auth and database setup in your Divjoy codebase
Click the ▶︎ icon next to any step to see a detailed walkthrough with screenshots.
Signup for an account at supabase.com or login to your existing account.
- Click the "Start your project" button and then login with Github
Create a new Supabase project
- Click the "New project" button
2. Specify a name, password and region
Copy your new project's Public Key, Secret Key, and URL into your codebase
- You'll see these values on the right side of the screen after creating your project
Go to Authentication settings and fill in your Site URL and Redirect URLs. The value for both should be your local development URL (generally
- Fill in the Site URL and Redirect URL values
Ensure Email Auth is enabled and that email confirmation settings are to your liking.
- You may want to change the email confirmation settings. In our case we opted to disable email confirmation and double-confirmation of email changes, but that depends on your preference and security needs.
[optional] Enable social auth providers. This will involve creating apps with each provider and adding your credentials. You can also come back to this step later, as it's not required to get your web app up and running.
- For example, to get Twitter auth working you'll need to go to https://developer.twitter.com, create an app, then fill in the client ID and secret.
Go the the SQL editor, click the "New query" button, paste in the contents of your codebase
schema.sql file and click "RUN". This will create your database tables, security policies, and triggers.
- When viewing your new project click the "SQL editor" button. From any page you can also click the icon on the left side (highlighted in the screenshot below).
- Click the "New Query" button in the top left
- Paste in the contents from
schema.sqland click the "RUN" button in the bottom right. You should then see the message "Success. No Rows returned" at the bottom.
- Before you move on to the next step, let's rename the SQL snippet you just ran to something other than "New Query" so that it's easier to find in the future. Try renaming it to "Create tables".
You can now view your tables and data in the Supabase Table Editor. As you build your app you'll likely want to come back to the table editor to add tables, columns, manually insert rows, etc.
- You can get to the table editor by clicking the icon on the left side (highlighted in the screenshot below).
- You can then browse, insert rows, and create new columns
Congrats! Supabase is all setup in your codebase. If you're already running your dev command you'll want to make sure to stop it (Ctrl + C) and re-run it so that it reads your updated
Why does it show a loading indicator forever after signing up?
The auth logic we give you in
src/util/auth.js automatically merges extra user data from the database and will fail if it's unreachable (causing it to be stuck in a loading state). You can check as to whether this is the issue by temporarily setting
const MERGE_DB_USER = false in
src/util/auth.js. To resolve this issue you'll want to follow the database instructions above. After the setup, make sure you delete any account from authentication that you've created while encountering this bug.
Why am I seeing errors when I try to run my app?
Make sure that all environment variables for all the services in your
.env file have values filled in. Also make sure the variables at the bottom (starting with
NEXT_) have values filled in.
Why don't I see all the social auth providers when viewing my app?
Assuming you are using the authentication components from the Divjoy library, you just need to go to
src/pages/auth.js and update the providers array on the
AuthSection component. For example, here's what it would look like if you want to display options for Google, Facebook, and Twitter.
Our authentication component supports the following by default:
github. You can add more options by configuring them in Supabase and then following this guide to display them in your component: Adding new login providers to Supabase.