Song-saem: From Planner to Developer with AIBlog home →
What Can You Build with AI?11 min read한국어로 읽기

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

StepWhat we doResult
1Create a Supabase project and a schedules tableA place to store schedules
2Add access rules (RLS)Logged-in people handle only their own schedules
3Add the connection settingsYour app can find Supabase
4Add loginAn entrance to your schedules
5Replace sample schedules with real savingSchedules 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()
);
ColumnMeaningLink to the part 4 data shape
idSchedule number, created automaticallyid
user_idOwner; the logged-in person’s ID goes in automaticallyNew
titleTitle; requiredtitle
dateDatedate
start_timeStart time; may be emptystartTime
memoMemo; may be emptymemo
doneDone or not; not done by defaultdone
created_atWhen it was created; recorded automaticallyNot 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.

TitleDateOwner
Prepare weekly meeting notesOct 21User A
Dentist appointmentOct 22User A
Another user’s appointmentOct 23User 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.

Only my schedules, with my account
Only my schedules, with my account
-- 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);
RuleMeaning
enable row level securityTurns on access rules for this table; with no policies, nothing is visible
to authenticatedApplies 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_idThe 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.

KeyUsed whereCaution
Publishable keyThe connection key used in the browserSafe to expose, but RLS must be on
Secret keyAdmin key for servers onlyBypasses 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.

Schedules that lived only on screen now stay in storage
Schedules that lived only on screen now stay in storage

6. How do you check that saving really works?

What to checkHowNormal result
LoginLog in with your emailYou land on the Today screen
Logged outLog out, then open /todayYou’re sent to /login
SavingAdd a schedule, then refreshThe schedule is still there
Edit, delete, doneTry each, then refreshYour changes stay
DatabaseOpen the Supabase Table EditorThe new row and its user_id appear
Someone else’s schedulesLog in with a second test accountIt can’t view, change or delete the first account’s schedules
Failed savesTry saving while disconnected or with a bad valueIt doesn’t show success; it explains the error
Key storageCheck the files going to GitHubNo .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.

Does it stay when reopened, and are other accounts blocked?
Does it stay when reopened, and are other accounts blocked?

7. What do you check first when something goes wrong?

SymptomLook first atAsk AI like this
The list is emptyLogin 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 stickThe 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 dayThe 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 breakThe Supabase dashboardCheck 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)

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?

  • #Supabase
  • #웹앱로그인
  • #데이터베이스저장
  • #나만의스케줄러
  • #스케줄러만들기
  • #AI코딩
Song-saem · Sanghwa Song, CEO of ONE-PEX

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 on the blog home →