Lesson 9 · How web apps workHow to add login to a website
Accounts, roles, and who sees what.
A login turns visitors into people your app recognises. Learn how sign-up, accounts and roles fit together, why the rules about who sees what belong next to the data, and how to ask the AI for a login that is safe from day one.
About 9 minutes to readLast updated
On this page
What a login gives your app
Without a login, every visitor is a stranger and sees the same thing. With one, your app knows who each person is: it can show a customer their own orders, let a member into a private area, and give the owner an admin page nobody else can open.
That makes a login one of the most valuable features you can add, and one of the most important to get right, because it is the front door to everyone’s information.
How a login works
Follow one visitor from the sign-up form to their own private page.
- Sign upThe visitor enters an email address and a password on the sign-up form, in the frontend.
- An account is createdThe backend creates their account in the database and keeps the password safely, never as plain text.
- A role is givenThe account gets a role, such as member. A few trusted accounts are given the admin role.
- Each person sees their ownWhen they sign in, access rules next to the data decide what they may see: their own bookings, never anyone else’s.
Roles: member, admin and more
A role is a label on an account that says what that person may do. Most apps start with two, and you can add more whenever your idea needs them.
| Role | Usually can | Usually can’t |
|---|---|---|
| Visitor (not signed in) | See public pages, sign up, send a form | See any account or private page |
| Member or customer | See and change their own details, bookings or orders | See anyone else’s, or the admin pages |
| Admin | See every record, manage members, change content | Nothing is hidden, so give this role with care |
Why the rules belong next to the data
Hiding a button is not the same as protecting the data behind it. If the only thing stopping a member from seeing someone else’s booking is that the page doesn’t show a link, a curious visitor can still find a way round it.
That’s why good apps keep the rules in the backend, right next to the data. In Supabase these are access rules on each table, often called row level security: the database itself checks who is asking before it hands anything over. When you ask the AI for a login, always say who may see what, so those rules are part of the build.
Logins in 3Edit
Connect your own Supabase first, then describe the accounts you want in plain words. The 3Edit Agent builds logins and roles, database tables and access rules in your Supabase, along with server routes.
Starting from a kit? The ecommerce starter kit already has customer accounts with sign-up and login and a store admin area. On a store built from it, the first account created becomes the admin, and you can add more admins by asking the chat.
Good practice for logins
- Ask for the rules, not just the screens: “Members see only their own bookings; admins see all” is the most important sentence in your prompt.
- Keep login messages calm and general: a failed login shouldn’t reveal whether an email has an account. The security basics guide explains why.
- Make yourself admin on purpose: decide which account is the admin, rather than letting every new account have the same powers.
- Test with two accounts: sign up as two different people, add something as each, and check neither can see the other’s. The testing guide walks you through it.
- Test signed out too: open a private window and try to visit a members’ page directly. It should ask you to sign in.
Try it in 3Edit.
This short project adds accounts to a running club website. Start a new project, connect your Supabase first, then paste the prompts in order and check each result in the live preview.
- 1Plan accounts and roles
I want a website for Riverside Running Club where members can sign up, log in and see a members’ area. Before you build anything, explain which roles you would create, what each role can see and do, and which access rules the database needs.
- 2Build sign-up and the members’ area
Build the website: a public home page about the club with a “Join the club” button, sign-up and login pages, and a members’ area with a “My runs” page where each member can log a run (date, distance in km and a note). Members must only ever see their own runs.
- 3Add an admin page
Add an admin role and an admin page that lists every member and their total distance this month. Make my account the only admin. Only admins can open this page, and the rule must be checked in the database, not just by hiding the link.
- 4Check it like a tester
Explain how I can test that one member can’t see another member’s runs, and that a signed-out visitor can’t open the members’ area or the admin page.
Then do the test yourself: sign up as two members in two different browsers, log a run as each, and make sure each one sees only their own.
Do it step by step.
This lesson explains the what, the why and the when. These guides and pages show every click.
- Connect Supabase to 3EditYour logins live in your own Supabase: create your free account, then connect it in a few clicks.Read the guide
- Security basics for vibe-coded appsRow level security, safe login messages and keeping secret keys on the server.Read the guide
- Test a vibe-coded app before launchSign-up, the two test users check and the production build, in a plain checklist.Read the guide
- Create your store admin accountOn a store from the ecommerce kit, the first account becomes the admin; add more by asking the chat.Read the guide
Next: Keys, server routes and keeping secrets safe
About the author.
Written by Humayun Rashed, founder of 3Edit. He also runs 3Edit’s free in-person AI website building and vibe coding course in London.
Questions people ask.
Yes. Each account is a record that has to be kept, and the app has to remember who is signed in. In 3Edit, logins live in your own Supabase.
A role is a label on an account, such as member or admin, that says what kind of user someone is. An access rule sits next to the data and decides what each role, or each person, may read or change.
Ask for access rules in the database that let each person see only their own records, then test with two accounts: sign up as two people, add something as each, and check neither can see the other’s. The testing guide shows how.
Ask the AI to add an admin role and make your account the admin. On a store built from the ecommerce starter kit, the first account created becomes the admin, and you can add more admins by asking the chat.
Yes. The 3Edit Agent builds logins and roles, database tables and access rules in your own Supabase. Your part is to say clearly who may see what, and to test it with two accounts before you launch.
Start vibe coding today.
Download 3Edit for Mac or Windows and build your first professional website in minutes.