Short-Video App with React Native and Supabase · Course book
Chapter 17: Finishing Touches
With the feed, uploads, comments, likes, follows, activity and chat in place, the short-video app is nearly complete. The last stage ties the features together into a finished product: a friends feed that shows only videos from mutual followers, profile photos that users can upload and change, a profile page with a grid of videos and statistics, sensible choices about which media is public, and live updates where they matter. This chapter explains each step, with the layout of the profile grid and the savings from resizing photos worked out by hand, and closes with a checklist for testing the whole app before showing it to anyone.
The friends feed
The Friends tab shows videos only from people who follow you and whom you follow, the mutual followers defined in the follow chapter. Its query is the home feed's query with one extra condition: the creator's id must be in the user's friends list. Reusing the same feed component, with the list of videos passed in as data, means the friends feed gets automatic playback, overlays, likes and comments for free.
A friends feed tends to be small, especially for new users, so its empty state matters. Rather than a blank screen, it can explain what friends are, "Friends are people you follow who follow you back", and suggest people to follow back from the activity feed. Keeping the friends set in the shared store, updated whenever the user follows or unfollows, means the friends feed always reflects the latest relationships without extra requests. Placing the Home and Friends feeds side by side, with the user able to switch between "For you" and "Friends" at the top of the screen, is a common alternative to a separate tab, and both designs can share the same component.
Profile photos and public buckets
Every user needs a picture: it appears on their videos, beside their comments, in chat and in the activity feed. Uploading one follows the same pattern as videos: the user picks an image with the image picker, choosing a square crop; the app uploads it to storage, at a path in the user's own folder; and the path is saved on the user's row.
Unlike videos, profile photos are seen everywhere by everyone, are small, and do not need protecting, so they suit a public bucket. Files in a public bucket have permanent addresses, built from the project's storage address and the file's path, which the app can create without asking the server. That has two benefits: no signing request is needed each time a picture is shown, and because the address never changes, phones and networks can cache the image, so it loads instantly the second time. Uploading only remains restricted: a storage policy allows users to write only into their own folder.
Caching brings one complication: if a user replaces their photo at the same path, other phones may keep showing the cached old picture. Saving each new photo under a new file name, for example with a timestamp, and updating the path on the user's row avoids stale images entirely, at the cost of deleting the old file to save space.
The profile page
A profile page has a header and a grid. The header shows the picture, the username, the three statistics, following, followers and likes received, and a button: "Edit profile" on your own profile, and "Follow" or "Following" on anyone else's. Below it, a grid of the user's videos, newest first, shows a thumbnail for each with its view or like count overlaid in a corner. Tapping a thumbnail opens that video full screen, with the rest of the user's videos available by swiping.
| Element | Data source | Own profile | Someone else's profile |
|---|---|---|---|
| Picture and username | User row | Tap to change the picture | Display only |
| Following and followers | Counts on the Follower table | Tap to see lists | Tap to see lists |
| Likes received | Count on Like where the owner is this user | Shown | Shown |
| Main button | Following set | Edit profile | Follow, Following or Message for friends |
| Video grid | Videos where the owner is this user | All own videos | Their videos |
The grid uses a FlatList with numColumns={3}, which arranges items in rows of three while still rendering only what is visible. Each tile's width comes from the screen width, and its height from the 9:16 shape of the videos.
On a 390-point-wide screen with 1-point gaps between the three columns, each tile is (390 − 2) / 3 = 129.3 points wide. A 9:16 tile is then 129.3 × 16 / 9 = 230 points tall, so two full rows, six videos, fit on screen below the header. Using thumbnails rather than live video in the grid keeps scrolling smooth and saves a great deal of data: a page of 18 thumbnails might total a few hundred kilobytes, while 18 videos would be hundreds of megabytes.
Two actions complete the profile. Editing the profile opens a form for the username and a short bio. Usernames must stay unique, so the form checks availability before saving, and the database's unique constraint remains the final guard against two people claiming the same name at the same moment. Deleting a video, offered only on the owner's own videos, needs two steps: removing the file from storage and deleting the Video row, whose cascading rules remove its likes and comments too. Asking for confirmation first is essential, because a deleted video cannot be recovered, and the policies on both the bucket and the table must allow deletion only by the owner. After either action, refreshing the profile and feed queries shows the change everywhere.
Media handling and live updates
By this point the app handles three kinds of media, each with its own best treatment. Videos are large and live in a private bucket, played through signed addresses. Thumbnails are small images shown in grids and lists, and can be public for fast, cacheable loading. Profile photos are small, public and resized before upload. Keeping each in its own bucket or folder, with its own policies, makes the rules easy to understand and audit. A short written note in the project describing each bucket, who may read it and who may write to it, helps anyone who works on the app later.
Some data benefits from real-time updates using the same subscriptions as chat. A creator watching their own video might see the like count rise live; new comments can appear in an open comment sheet without refreshing; and when someone changes their profile photo, their picture can update across open screens. Subscriptions use resources, so they are best kept for screens the user is actively watching, and paired with a refetch when the app returns to the foreground, so nothing missed while offline is lost.
Finally, cached queries should be refreshed after every change the user makes: uploading a video should refresh the profile grid and the feed; changing the photo should refresh every query that displays it; following someone should refresh the friends feed. With TanStack Query, invalidating the relevant query keys after each mutation keeps the whole app consistent with very little code.
Testing the finished app
Before showing the app to anyone, test the complete journey on real phones, both iOS and Android: sign up a new account, upload a profile photo, record a video and pick one from the gallery, watch the feed, like, comment and share, follow another test account and have it follow back, check the friends feed and the activity feed, send chat messages in both directions, then sign out and in again. Try it on a slow network and in airplane mode to see how errors appear. Each problem found now is one that real users will never meet. The final step, covered next, is preparing the app for the App Store.
Practice tasks
- On a 428-point screen with three columns and 2-point gaps, how wide and tall is each 9:16 tile?
- A 4,032 × 4,032 photo is resized to 320 × 320. What percentage of the pixels remain?
- Explain why profile photos suit a public bucket while videos stay in a private one.
- Why should a replaced profile photo be saved under a new file name?
- Which queries should be refreshed after a user uploads a new video?
- Write a test plan of ten steps that covers every major feature of the app.
This course book is available to read online only at tech-academy.chrysolites.org.