Mode
Guest mode
A visitor without a Supabase session keeps using eventmap:favorites and eventmap:favorite-events in localStorage.
EventMap now switches favorites by auth state: guests keep browser persistence, authenticated users use the Supabase favorites table.
Mode
A visitor without a Supabase session keeps using eventmap:favorites and eventmap:favorite-events in localStorage.
Mode
An authenticated user reads and writes public.favorites through the browser client and RLS-scoped policies.
Mode
On first sign in, cached local EventCardData snapshots are copied to Supabase. The local cache stays in place as guest fallback.
Hook boundary
The hook reads the current Supabase user in the browser after hydration. If there is no configured client or no user session, it delegates to the existing localStorage favorites hook.
guest localStorage → login → copy snapshots → cloud favoritesCRUD
useFavoritesCloud loads event_id and event_snapshot from public.favorites. RLS limits the result to the current auth.uid().
CRUD
Saving an event inserts user_id, event_id and event_snapshot. No upsert is used because this lesson has no UPDATE policy.
CRUD
Removing a favorite deletes the matching user_id and event_id row, then the UI updates optimistically.
Boundary
/favorites stays a normal EventMap page. It shows events, empty state and a link back to search.
Boundary
FavoriteButton remains the small client island inside server-rendered event cards.
Boundary
SQL, RLS and CRUD explanations stay here instead of leaking into product UI.