Zero to Dollar.
0%

Database & Customer Accounts

Goal: Make the app save real data, let people sign up and log in, and give each customer their own page.

What we're doing

Right now your app looks great — but it's all fake. Refresh the page and everything resets. There are no real customers, no saved data, nothing permanent.

In this module, we make it real. By the end:

  • People can sign up with their email and log in to the app
  • Everything they create — their links, their colors, their layout, their bio, all of it — gets saved to their account
  • When they come back and log in, it's all still there
  • Their public page at yourdomain.com/page/username shows their saved data to the world

This is how real apps work. Let's set it up.


What is Supabase?

Supabase does two things for us:

  1. Authentication — It handles sign-up and login. Email, password, sessions — all of it. We don't have to build any of that from scratch.

  2. Database — It stores everything. Every link someone adds, every color they pick, every bio they write. It's like a spreadsheet in the cloud that your app reads from and writes to automatically.

It's free to start and it's designed to work with apps exactly like ours.

Why can't we just save things to the computer?

When your app is live on the internet, it runs on a temporary server that resets every time you update your site. "Saving to a file" doesn't work because that file gets wiped clean during the reset. You need a database—a permanent storage box in the cloud that stays put no matter what.


Step 1: Create a Supabase account and project

Verification

Success: Your project status in the Supabase dashboard shows as Active (green light) and you can see the full project sidebar.

Supabase Dashboard


Step 2: Connect the Agent to Supabase

Instead of copying keys and URLs back and forth between Supabase and your Agent, we're going to give the Agent a direct connection to your Supabase project. This uses something called MCP — think of it as giving the Agent its own login to Supabase. Once connected, the Agent can set up your database, grab your project details, and manage everything directly. No copy-pasting required.

Verification

Success: The Agent lists your project name and project ID accurately. Failure: If the Agent says "I don't have access" or "Project not found," check that your access token was set to "Never" expire and try reconnecting.


Step 3: Connect your app to Supabase

Now that the Agent has direct access to your Supabase project, let's have it wire everything up.

AI PromptSet up Supabase in Linktree-clone — Put this in your IDE

Use your Supabase MCP connection to set up Supabase in Linktree-clone. Get my project URL and API ke...

Click to expand
Verification

Success: You see a new .env.local file in your project explorer containing your NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY. You should also see new library files (like supabase.ts) that the Agent created to handle the connection.


Step 4: Set up sign-up and login

Now we add customer accounts. Supabase handles all the login logic — we just need to configure a couple of things and build the pages.

Important: the dashboard stays open to everyone. People should be able to visit the dashboard, build their page, pick colors, add links — all without signing up first. They only need to create an account when they click Save (to save their work) or Publish (to make their page live). This way people can try before they commit.

Why do we need redirect URLs?

When someone signs up or logs in, Supabase handles the verification and then sends them back to your app. If your URL isn't on the approved list, Supabase refuses to redirect — and the login just silently breaks. This is the #1 thing that trips people up, so double-check both URLs are added.

Now let's build the actual sign-up and login pages.

AI PromptBuild sign-up and login pages — Put this in your IDE

Use your Supabase MCP connection throughout — do not ask me to copy or paste anything into Supabase....

Click to expand
Verification: Auth

Success:

  1. Sign up: You sign up and land on the dashboard instantly — no email confirmation required.
  2. Login: Log out (from the Account tab), go to /login, and log back in — you land on the dashboard.
  3. Navigation: When logged in, the Login and Get Started buttons are replaced by a Dashboard button. When logged out, they reappear.
  4. Forgot password: On the login page, click "Forgot password?", enter your email, and check your inbox. Click the link in the email — you should land on /reset-password, not the login page. Enter a new password twice and confirm it. You should be automatically logged in and land on the dashboard.
  5. Dashboard: Go to your Supabase dashboard, then Authentication > Users. You'll see all your users here. If necessary, you can add or delete them here manually.

Supabase Users

These five things only test authentication. Saving and persistence across sessions is tested after the database is set up in Step 5.


Step 4b: Save your work

Before we move on to the database, let's save what we've built so far to GitHub.

AI PromptSave to GitHub — Put this in your IDE

Save all my work to GitHub. Stage everything — including any new pages, Supabase configuration files...

Click to expand

Step 5: Build the database and save everything

Now that customers can sign up, we need somewhere to save their data. This is the big one: everything about a customer's page gets saved to the database. Their links, their bio, their colors, their background, their social media handles, their payment settings — literally everything. When someone logs in, their entire page is loaded exactly as they left it.

We also need security rules so that each person can only edit their own page. Without this, anyone could change anyone else's data.

What are "security rules"?

Imagine your database is an apartment building. Right now every door is wide open — anyone can walk into any apartment. Security rules (called "Row Level Security" in Supabase) are the locks on the doors. Each person gets a key that only opens their own apartment. Visitors can see the lobby (public pages), but they can't get into anyone's unit.

The app has two important buttons that do different things:

  • Save — saves the customer's work to the database. Their page is still private (draft mode).
  • Publish — saves their work AND makes their page live at domain.com/page/username for the world to see. Publishing requires payment ($12/year), which we'll wire up in the next module. For now, the Publish button should exist but the payment part won't work yet.
AI PromptSet up the database and connect everything — Put this in your IDE

Read my blueprint.txt. Use the Supabase MCP connection to set up the entire database. Run all SQL di...

Click to expand

Note: This is a big step! It can take a few minutes for the Agent to build the entire database and connect everything.

Pro Tip

Just tell the Agent what you see. Tell it what is not working and it will find and fix the problem.

Verification: Database Tables & Saving

Success:

  1. Tables exist: Go to Supabase → Table Editor. You should see tables like profiles and links already created.

    Table Editor

  2. Save works: Change your Bio on the dashboard and click Save.

  3. Persists on refresh: Hard-refresh the page (Cmd+R / Ctrl+R) — your changes should still be there.

  4. Persists across sessions: Open a fresh incognito window, log in with your test account — everything should look exactly as you left it.


Step 6: Test the complete flow

Before we push anything, let's make sure the whole thing works end to end.

The publish flow — where the customer pays to make their page go live — gets wired up in the next module when we add Stripe. For now, manually flipping is_published in Supabase lets us test that the public page works correctly.

Remember the difference: Save keeps your work safe but private. Publish makes it live for the world to see (and requires payment).


Step 7: Deploy to Vercel

Your app works locally — now let's make sure the live site works too. We need to tell Vercel about the Supabase connection.

AI PromptPush to GitHub and Vercel — Put this in your IDE

Save all my work to GitHub. Stage everything, commit it with a clear message about what was built (S...

Click to expand
Verification

Your app is now live. Go through the same test steps from Step 6 again — but this time on your live Vercel URL, not localhost. Sign up, save, refresh, log out, log back in, test the public page. Everything that worked locally should work the same way in production.

Ready to move on?