Get your API key

Lesson 5 mein se 6

Data sahi tarike se save karo

Pehle browser storage, phir security rules ON ke saath Supabase database.

9 min Login karke kholo
Ek baar mein ek step, page palatne jaisa.

Is lesson ke end tak aapke routines aur ticks refresh ke baad bhi bache rahenge: pehle browser storage mein, phir Supabase database mein jahan har user sirf apna data dekhta hai, security rules ON ke saath.

Aapko chahiye: lesson 4 ki working screens, free Supabase account, aapka coding agent · Time: 8 minute

  1. Abhi aapke routines page ki memory mein hain, isliye refresh karte hi gayab. Sabse jaldi fix hai localStorage: browser ke andar ek chhoti si notebook, har website ke liye alag.

    Iske baare mein yeh jaan lo:

    • Refresh aur browser band karne ke baad bhi data rehta hai.
    • Har website ke liye lagbhag 5 MB jagah, hazaaron routines ke liye kaafi.
    • Yeh ek device ke ek browser mein rehta hai. Phone aur laptop ki copy alag-alag hoti hai.
    • User browsing data clear kare toh delete ho jaata hai, aur private (incognito) window mein shayad save hi na rahe.
    • Us browser ko use karne wala koi bhi ise padh sakta hai, isliye password ya private data isme kabhi mat rakho.
    Prompt · ise apne AI agent mein paste karo
    Read PRD.md first.
    Save all routines and daily ticks in localStorage so they survive a page refresh and closing the browser.
    Rules:
    - Use one localStorage key called "daily-routine-v1".
    - Store each tick by date as YYYY-MM-DD using the LOCAL date of the device, not the UTC date (I am in India, IST, and the day must change at midnight IST, not at 5:30 am).
    - If the saved data is missing or broken, start with an empty list and show the empty state; never crash.
    - Do not change how any screen looks.
    When done, tell me 3 steps to test it, including a refresh test.
    Kyun?

    localStorage ke liye na account chahiye, na server, na keys, isliye yeh sabse safe pehla kadam hai. Local date wala rule India mein bahut zaroori hai: kai apps galti se UTC date use karte hain, phir "aaj" subah 5:30 baje badalta hai aur har streak toot jaata hai.

Baaki lesson padhne ke liye free login karo

Har lesson free hai. Free account se saare lessons khul jaate hain aur aapki progress save hoti hai.

Is lesson mein aage:

  1. Test karo ki sach mein save ho raha hai
  2. Zaroorat ho tab Supabase par jao
  3. Apni do keys pehchano
  4. RLS ON karo, asli policies ke saath
  5. Security Advisor aur do users se check karo
  6. Recap