START HERE
β
Do multiple people need to access this data?
β β
YES NO
β β
β USE LOCAL STORAGE
β
Does the data already exist in another system?
β β
YES NO
β β
USE API USE SUPABASE
| Feature | Local Storage | Supabase | External API |
|---|---|---|---|
| Speed | β‘β‘β‘ Fastest | β‘β‘ Fast | β‘ Varies |
| Offline | β Yes | β No | β No |
| Share Data | β No | β Yes | β Yes |
| Multi-Device | β No | β Yes | β Yes |
| Backup | β No | β Auto | β Yes |
| Setup | β Easy | ββ Medium | βββ Complex |
| Cost | π° Free | π° Free tier | π°π° Varies |
| Control | π― Full | π― Full | π Limited |
| Storage Size | ~5-10MB | Several GB | Unlimited |
| Best For | Learning, Single-user | New apps, Multi-user | Integration |
A notebook in your pocket - data stays on your device.
Store the form data in local storage.
When form is submitted:
- Save data with key: "registrations"
- Format: JSON.stringify(dataArray)
- Log: "Saved to local storage"
When app loads:
- Load from key: "registrations"
- Parse: JSON.parse(storedData)
- If null, use empty array: []
- Display loaded data
USER INPUT β VALIDATE β localStorage.setItem() β DATA SAVED
β
PAGE REFRESH β localStorage.getItem() β PARSE β DISPLAY
Pros: - π Instant (no network delay) - πΎ Works offline - π― Simple to implement - π° Free - π Private to device
Cons: - β Lost if app deleted - β Canβt sync between devices - β Limited storage (~5MB) - β Not backed up - β Single user only
Like Google Sheets meets Database - shared storage in the cloud.
Connect to Supabase and store data there.
Credentials:
- URL: [YOUR_SUPABASE_URL]
- Key: [YOUR_ANON_KEY]
- Table: registrations
When form is submitted:
1. Validate data
2. Save to Supabase:
const { data, error } = await supabase
.from('registrations')
.insert([formData])
.select()
3. If successful:
- Show success message
- Refresh list
- Clear form
4. If error:
- Show error message
- Log error to console
- Keep form data
USER INPUT β VALIDATE β SEND TO CLOUD β SUPABASE SAVES
β
PAGE LOAD β REQUEST DATA β SUPABASE RETURNS β DISPLAY
Pros: - βοΈ Cloud-based (access anywhere) - π₯ Multi-user support - πΎ Automatic backups - π Real-time sync - π Visual dashboard - π Built-in security (RLS) - π° Free tier available
Cons: - π Requires internet - β±οΈ Network latency - π Learning curve - βοΈ Setup required
Connecting to data that lives in another companyβs system.
Connect to external API and fetch data.
API Details:
- Endpoint: https://api.example.com/v1/items
- Method: GET
- Authentication: Bearer Token
- Token: [PROVIDED_BY_IT]
Fetch data:
1. Make API request with auth header
2. Show loading indicator
3. If successful:
- Parse response data
- Display in list
- Show count
4. If error:
- Show error message
- Log error details
- Provide retry button
Log all API calls for debugging.
YOUR APP β API REQUEST β EXTERNAL SYSTEM
β
PROCESSES
β
YOUR APP β API RESPONSE β RETURNS DATA
β
DISPLAY
Pros: - π Access existing data - π’ Enterprise integration - π Live data (always current) - π Secure (managed by IT) - π Scalable
Cons: - π Limited control - π« Need credentials/permissions - π Fixed data structure - π Harder to debug - β±οΈ Depends on their uptime - π° May have costs
Step 1: Set up Supabase - Create account and project - Create table matching your data structure - Get credentials
Step 2: Update Save Operation
Change from:
localStorage.setItem('key', JSON.stringify(data))
To:
await supabase.from('table').insert([data])
Step 3: Update Load Operation
Change from:
JSON.parse(localStorage.getItem('key'))
To:
const { data } = await supabase.from('table').select('*')
Step 4: Update Delete
Change from:
// Remove from local array and save back
To:
await supabase.from('table').delete().eq('id', itemId)
Use when: Company requires using their existing system
Changes needed: 1. Replace Supabase endpoints with API endpoints 2. Add authentication headers 3. Handle different response format 4. Canβt create/modify data structure
Best: External API or Supabase
- Just displaying existing data
- No user modifications
- Example: Product catalog
Best: Local Storage or Supabase
- Add new items
- View all items
- Example: Notes app, visitor log
Best: Supabase
- Complete data management
- Multiple operations
- Example: Student management
Use: Supabase + API
- Store app data in Supabase
- Fetch reference data from API
- Example: Order app (orders in Supabase, products from API)
Problem: Data disappears
Fix:
- Verify key name is consistent
- Check data is stringified before save
- Ensure save happens before app closes
Problem: Data not loading
Fix:
- Check key name matches
- Handle null case (no data yet)
- Parse JSON correctly
Problem: Canβt connect
Fix:
- Verify URL format (https://xxx.supabase.co)
- Check API key (starts with eyJ)
- Confirm RLS policies allow access
- Test internet connection
Problem: Data not appearing
Fix:
- Check table name spelling
- Verify column names match
- Review RLS policies
- Check browser console for errors
Problem: 401/403 errors
Fix:
- Verify API key/token is correct
- Check authentication header format
- Confirm permissions with IT team
- Token may have expired
Problem: CORS errors
Fix:
- Contact IT team (server-side fix needed)
- Cannot be fixed in client app alone
- May need proxy or different approach
Store data in local storage:
- Key: "[YOUR_KEY]"
- Format: JSON array
- Save after: [TRIGGER]
- Load on: page load
- Handle empty case: use []
Connect to Supabase:
- URL: [YOUR_URL]
- Key: [YOUR_KEY]
- Table: [TABLE_NAME]
CRUD Operations:
- Create: .insert([data])
- Read: .select('*')
- Update: .update(changes).eq('id', id)
- Delete: .delete().eq('id', id)
Connect to API:
- Endpoint: [URL]
- Method: [GET/POST/PUT/DELETE]
- Auth: [Bearer/API Key/Basic]
- Headers: [REQUIRED_HEADERS]
Handle response:
- Success: [ACTION]
- Error: [ERROR_HANDLING]
βββββββββββββββββββββββββββββββ
β What are you building? β
ββββββββββββ¬βββββββββββββββββββ
β
ββββββββ΄βββββββ
β β
Practice/ Real App
Learning β
β β
LOCAL Is it for
STORAGE multiple users?
β
ββββββ΄βββββ
β β
NO YES
β β
LOCAL or Connect to
SUPABASE existing system?
β
ββββββ΄βββββ
β β
YES NO
β β
API SUPABASE
π― Local Storage: Fast, offline, single-user βοΈ Supabase: Shared, backed up, multi-user π API: Integration, existing systems
Choose based on your specific needs!
Print this and keep it handy!
Version 1.0 | eMOBIQ AI Workshop Materials Β© Orangekloud Technology Inc.