Setting up the database
After registering for a free account on Supabase (https://supabase.com/), you’ll end up in the dashboard to create a new project. Let’s use fitness-tracker
as the name and choose a strong database password. For the region, pick one that is geographically close to you for better latency. We’ll stick with the free plan!
On the next page (Figure 6.2), you will see the project API keys:
Figure 6.2 – Overview of the project API keys
We’ll store them in our .env
file in the root of our project:
VITE_SUPABASE_URL=YOUR_SUPABASE_URLVITE_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY
Note that sharing keys like this via a client-side app always exposes them to the public. Luckily, Supabase has its own means of ensuring authentication while interacting with the database.
I’ve created a script that sets up the database with the table structure for our app. Via the dashboard and SQL editor, you...