🧠📘🚀 Reliable onboarding with Supabase
🎯✨ MAIN OBJECTIVE
Design an onboarding flow that:
✅ Builds trust
✅ Guides the user correctly
✅ Prevents repeating onboarding
✅ Works well from the first use
🧩⚙️ KEY SYSTEM COMPONENTS
🟦 Multi-step onboarding form
🟦 profiles table
🟦 Boolean field onboarding_completed
🟦 Real-time updates
🚶➡️🧭 USER FLOW
1️⃣ User creates an account
⬇️
2️⃣ Automatic redirection to onboarding
⬇️
3️⃣ Completes step-by-step form (slides)
⬇️
4️⃣ Answers are saved in the database
⬇️
5️⃣ Onboarding finished
🔹 onboarding_completed = true
⬇️
6️⃣ Future visits
➡️ ❌ Onboarding is skipped
➡️ ✅ User goes directly to the dashboard
🗂️👤 DATA MODEL: profiles
📌 Central table with user data
🧾 Stored information
🔹 Job title
🔹 Primary use case
🔹 Company name
🔹 Personal preferences
✍️ Examples
🧑💼 Job title: “CEO of Imaginary Space”
🏢 Use case: enterprise asset management
⚙️ Preferences:
📧 Email notifications
🖼️ Image sources
💰➕ OPTIONAL UPSELL
📍 Appears at the end of onboarding
🔸 Shows prices and plans
🔸 Invites the user to upgrade
🔸 Before starting the free plan
⚠️ Does not block the main flow
🚨🐞 COMMON ERROR
❌ Onboarding completed
❌ Data saved
❌ Success message
❌ App returns to step 1
🔍 KEY CLUE
🟡 It only works on the second attempt
🧠⚠️ ROOT CAUSE
🔴 The app state does not update immediately
- The database already has the correct value
- The app still believes onboarding is not finished
- Redirection does not trigger
🧪🗣️ DIAGNOSIS
💬 Using Lovable chat mode with:
✔️ Steps performed
✔️ Expected result
✔️ Actual result
🎯 Clear context → issue identified
✅🔔 RELIABLE SOLUTION
🟢 Add a real-time subscription to profiles
📡 When:
- onboarding_completed changes to true
🚀 Then:
➡️ Immediate redirection to the dashboard
⚠️🔄 ALTERNATIVE SOLUTION
🔁 Force a full page reload
✔️ Works
❌ Not elegant