Connecting Saving and Login to a Web App: Store Only Your Own Schedules with Supabase (Build Your Own Scheduler, Part 6)
We replace the sample schedules from part 5 with real saving. This post covers creating a schedules table in Supabase, adding the connection settings, adding email login, and using access rules (RLS) so you only see and change your own schedules. It includes a request to hand AI and a table for checking that saving really works.

How do you add saving and login to a web app? Order matters. Make a table for schedules, connect the app, add login, then put a “only my schedules” access rule on the database itself. Login confirms who you are; access rules decide which schedules you can see and change. Build only a login screen and skip the access rule, and the database may be open even though the app looks locked. In this part we connect Supabase saving and login to the part 5 screens, so schedules stay after a refresh. This is part 6 of the “Build Your Own Scheduler” series.
What this part does
| Step | What we do | Result |
|---|---|---|
| 1 | Create a Supabase project and a schedules table | A place to store schedules |
| 2 | Add access rules (RLS) | Logged-in people handle only their own schedules |
| 3 | Add the connection settings | Your app can find Supabase |
| 4 | Add login | An entrance to your schedules |
| 5 | Replace sample schedules with real saving | Schedules stay after a refresh |
Putting it on the internet and adding it to your phone’s home screen come in part 7. We still check everything on your PC (localhost).
1. How do you create the Supabase project and table?
Supabase is a service that provides a database and login together (introduced in part 2). Sign up at supabase.com and create a new project. The free plan allows 2 active projects, and free projects are paused after 1 week of inactivity. For a scheduler you use daily that’s rarely a problem; if it won’t open after a break, restart it from the dashboard.
If the dashboard is unfamiliar, ask AI: “I’m new to development. I want to create a Supabase project for a scheduler. Tell me step by step where to click on this screen, and move to the next step after I show you the result.” Hide passwords and secret keys when you show your screen. Your account for managing Supabase and the account you will use to log in to your scheduler are separate.
Next is the schedules table. The “information to save” from the part 3 brief and the data shape from part 4 (types/schedule.ts) become the table’s columns. Added to them is a column marking whose schedule it is (user_id).
-- Create the schedules table
create table public.schedules (
id uuid primary key default gen_random_uuid(),
user_id uuid not null default auth.uid() references auth.users (id) on delete cascade,
title text not null,
date date not null,
start_time time,
memo text,
done boolean not null default false,
created_at timestamptz not null default now()
);| Column | Meaning | Link to the part 4 data shape |
|---|---|---|
| id | Schedule number, created automatically | id |
| user_id | Owner; the logged-in person’s ID goes in automatically | New |
| title | Title; required | title |
| date | Date | date |
| start_time | Start time; may be empty | startTime |
| memo | Memo; may be empty | memo |
| done | Done or not; not done by default | done |
| created_at | When it was created; recorded automatically | Not used on screen |
The database writes column names with underscores like start_time, while code uses startTime. Let AI build the part that connects the two.
2. Why are access rules (RLS) essential?
This is the most important part of this post. Supabase’s docs say a table without RLS is readable and writable by any role with a grant on it, and tell you to enable RLS on every exposed table. Your app’s connection key (the publishable key) is visible in the browser, so without access rules that key alone could reveal other people’s schedules.
RLS (Row Level Security) makes the database itself check “who can see and who can change this row (one schedule).” For the scheduler, the rule is “only when the logged-in person’s ID matches the schedule’s user_id.” Hiding other people’s schedules on screen is different from the database blocking access; RLS makes the storage itself check the rule.
| Title | Date | Owner |
|---|---|---|
| Prepare weekly meeting notes | Oct 21 | User A |
| Dentist appointment | Oct 22 | User A |
| Another user’s appointment | Oct 23 | User B |
When A is logged in, A should handle only A’s schedules, not only when viewing but also when adding, changing and deleting. Turning RLS on isn’t the end; you also need policies that say under what conditions access is allowed.

-- Turn on access rules
alter table public.schedules enable row level security;
-- See only my schedules
create policy "View own schedules" on public.schedules
for select to authenticated
using ((select auth.uid()) = user_id);
-- Add only as my own
create policy "Add own schedules" on public.schedules
for insert to authenticated
with check ((select auth.uid()) = user_id);
-- Change only mine
create policy "Update own schedules" on public.schedules
for update to authenticated
using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);
-- Delete only mine
create policy "Delete own schedules" on public.schedules
for delete to authenticated
using ((select auth.uid()) = user_id);| Rule | Meaning |
|---|---|
| enable row level security | Turns on access rules for this table; with no policies, nothing is visible |
| to authenticated | Applies to logged-in people only |
| using (...) | Among existing rows, only matching ones can be seen, changed or deleted |
| with check (...) | New or changed rows must also match to be saved |
| (select auth.uid()) = user_id | The logged-in person’s ID equals the schedule’s owner |
A common surprise: if the list goes empty after turning on RLS, you usually haven’t created the policies yet. The docs say that once RLS is enabled, no data is accessible with a publishable key until you create policies. The fix is to add policies, not to turn RLS off.
3. Where do the connection settings go?
From the Supabase project, copy the project URL and the publishable key into the .env.local file at the top of your project. It’s the “connection settings for my computer” file from part 4.
# .env.local (never pushed to GitHub)
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...Supabase has two kinds of keys.
| Key | Used where | Caution |
|---|---|---|
| Publishable key | The connection key used in the browser | Safe to expose, but RLS must be on |
| Secret key | Admin key for servers only | Bypasses RLS; never put it in screen code, a chat, or GitHub |
The publishable key doesn’t tell users apart. Login identifies the user, and RLS policies limit what data they can handle. Also, .env.local isn’t pushed to GitHub, but values starting with NEXT_PUBLIC_ are sent to the browser. Writing a value in this file doesn’t make it secret, so never put the secret key under such a name.
The docs say the older anon and service_role keys are being deprecated by the end of 2026. If an older post or an AI answer mentions them, read them as publishable and secret keys. After editing .env.local, restart the development server (npm run dev) for it to take effect.
4. Which login method should you use?
Supabase supports email and password, magic links (logging in via a link sent by email), and social logins like Google and Kakao. For a scheduler just for you, email and password is the simplest.
- If email confirmation is on, finish the confirmation step from the email you receive after signing up before logging in.
- After testing, you can turn off new sign-ups in Supabase’s auth settings. But blocking sign-ups doesn’t replace RLS policies.
- Kakao login works too, but there’s more to prepare; for example, using Kakao’s email consent item requires switching to a Biz App. Starting with email and switching later is easier.
- Make /today redirect to /login when you’re not logged in.
5. What do you hand to AI?
As in part 5, hand over what, how far, and how to check together. Be especially clear about access rules and keys.
I want to connect Supabase saving and login to the scheduler I built in part 5. I’m new to development. 1. Keep the existing screens and features, and save and load real schedules instead of the sample ones. 2. Give the schedules table a title, date, start time, memo, done flag and an owner user_id. 3. Turn on RLS and prepare policies so logged-in people can view, add, change and delete only their own schedules. 4. Follow Supabase’s official Next.js guide and use the publishable key. Don’t use the secret key, and don’t show key values in your answer. 5. Build an email and password login screen and a log-out button. If I’m not logged in, send me to the login screen. 6. Update the screen after saving succeeds, and show a message if it fails. 7. First check the current project and explain the files to change and the order. Show me any SQL that changes tables or policies before applying it. 8. Go one step at a time, and tell me what I should check.
If you already created the table and policies with the SQL in sections 1 and 2, ask AI to check the existing setup instead of creating new ones. If not, have it guide you through the SQL to create and how to apply it. Item 7 matters most when your AI coding tool is connected to the database; it’s safer to review structure changes before they’re applied.

6. How do you check that saving really works?
| What to check | How | Normal result |
|---|---|---|
| Login | Log in with your email | You land on the Today screen |
| Logged out | Log out, then open /today | You’re sent to /login |
| Saving | Add a schedule, then refresh | The schedule is still there |
| Edit, delete, done | Try each, then refresh | Your changes stay |
| Database | Open the Supabase Table Editor | The new row and its user_id appear |
| Someone else’s schedules | Log in with a second test account | It can’t view, change or delete the first account’s schedules |
| Failed saves | Try saving while disconnected or with a bad value | It doesn’t show success; it explains the error |
| Key storage | Check the files going to GitHub | No .env.local and no secret key |
The “someone else’s schedules” check is the key one. Testing only with your own account makes it hard to notice a missing access rule. Not seeing them in the list isn’t enough to say every policy is right, so have AI verify with test data that attempts to change or delete the first account’s schedules are refused. After testing you can clean up the second account and turn off new sign-ups, but that setting doesn’t replace RLS.

7. What do you check first when something goes wrong?
| Symptom | Look first at | Ask AI like this |
|---|---|---|
| The list is empty | Login state, user_id, the select policy, date conditions, table access grants | “My schedules don’t show. Don’t turn RLS off; check the login state, user_id, select policy, date conditions and table access grants. Explain the cause and what you’ll change first.” |
| Saving doesn’t stick | The insert policy and user_id | “Adding gives an error. Check the insert policy’s with check and the user_id value.” |
| Connection error | .env.local values and a server restart | “I get a Supabase connection error. Check the .env.local names match the code. Don’t show the key values.” |
| Dates shift by a day | The code that builds dates | “Saved dates shift by one day. Check for any conversion to UTC, as in part 5.” |
| Won’t open after a break | The Supabase dashboard | Check whether the free project was paused, and restart it |
Turning off access rules because schedules don’t show may make them appear for now, but it creates other problems. Find out why they don’t show first.
In short
- Add saving and login in this order: table, access rules, connection settings, login, real saving.
- A login screen alone isn’t enough. Turn on RLS in the database and create “only my schedules” policies.
- The publishable key is fine in the browser; the secret key never goes in screen code, a chat or GitHub.
- You’re not done until a second account confirms it can’t view, change or delete someone else’s schedules.
- Don’t let AI run structure-changing SQL straight away; review it first.
At ONE-PEX, when we build the business system FROX, we also check access rules before screens. Different staff can see different data, so hiding buttons on screen isn’t enough; the database itself has to block it.
Next (Part 7): We put the scheduler, which so far opens only on your PC, on the internet, and add it to your phone’s home screen like an app for daily use.
Sources (checked 2026-10-20)
- Supabase docs, Use Supabase with Next.js
- Supabase docs, Row Level Security
- Supabase docs, Auth
- Supabase docs, API keys
- Supabase, Pricing
Related reading: Build Your Own Scheduler, Part 4: Web app code structure · Part 5: Building web app screens · How much did AI change in one year?

A software planner who became a developer after two years of working with AI five to twelve hours a day. Today I build FROX, an AI-powered business system, at ONE-PEX.
More posts
- What Can You Build with AI?Orders in KakaoTalk, Stock in Excel, Receivables in a Notebook: Changing Messenger Orders Only the Owner Understands (Food Supplier, Part 1)
- What Can You Build with AI?I Fixed My TWA App, So Why Didn't It Change? What I Learned from the War with Caching
- What Can You Build with AI?Details Matter: Splitting 3D Characters and Vehicles So They Can Move (Building Road Voca 2, Part 5)
