In plain words
An array is an ordered list of values, like posts in a feed or items in a cart, where each item has a numbered position starting at 0.
Where you see it
Square brackets are the giveaway. Chirp's feed is an array of posts, and posts[0] is the one at the top. When you select rows from Supabase you get an array back, even if it holds one row or none.
What goes wrong
- Reading [1] to get the first item
The first item lives at [0]. Asking for [1] gets the second, so your "latest post" banner shows yesterday's.
- Expecting one row and getting a list
A Supabase select returns an array, so data.name is undefined when you meant data[0].name. Add .single() when you want exactly one row.
- Treating an empty array as missing
An empty array still counts as true, so if (posts) passes with no posts at all. Check posts.length === 0 to show an empty state.
if (!posts) showEmptyMessage(); // never runs for []
What to tell your agent
Quick check
Sign in to earn +10 XP for itYour Chirp feed is empty, yet the "No posts yet" message never appears. The code says if (!posts). Why?