Hashtags in the TikTok-Style React Native App
Hashtags connect composer captions to discover and feed surfaces. They are usually extracted on post creation, stored with the post, and indexed in Firestore so the app can group or query related posts.
Quick Answer
When a user creates a post, the app parses hashtags from the caption, stores the array on the post payload, writes hashtag index documents if the backend/provider supports it, then the discover screen groups or queries posts by hashtag.
Composer Flow
The post composer usually performs this sequence:
- user enters caption text;
- app extracts hashtag tokens such as
#travel; - app normalizes tokens if needed;
- app includes
hashtagsin the post object; - post API writes the post and related hashtag index data;
- feed/discover screens read the resulting data.
Search the app source:
rg "hashtag|hashtags|findHashtag|findHashtags|Discover" src
Avoid relying on fixed line numbers because generated app versions can move code between screens, hooks, and core provider files.
Suggested Hashtag Parser Rules
For production apps, define consistent behavior:
- keep hashtags case-insensitive for search;
- preserve original display text if needed;
- strip trailing punctuation;
- reject empty tags;
- limit the number of tags per post;
- avoid indexing private or deleted posts;
- moderate abusive tags if the app allows public UGC.
Firestore Shape
Exact collection names can vary, but common patterns include:
posts/{postId}
entities/social_feeds_hashtags/{hashtag}/posts/{postId}
or a similar hashtag index collection.
The post document should keep enough metadata for display:
{
authorID: 'user-id',
postMedia: [...],
caption: 'Beach day #travel',
hashtags: ['travel']
}
Discover Screen
The discover screen can either:
- read grouped hashtag index collections; or
- load recent posts and group them client-side for small datasets.
For production feeds, prefer indexed queries with Firestore indexes and limits. Avoid loading a large global feed only to group it on the client.
Verification Checklist
- Caption parser extracts expected tags.
- Post document contains a
hashtagsarray or equivalent field. - Hashtag index documents are created if the app uses them.
- Discover screen shows grouped hashtag sections.
- Tapping a hashtag shows related posts.
- Deleted or blocked content is removed from public hashtag surfaces.
Troubleshooting
| Problem | Fix |
|---|---|
| Hashtags are not saved | Check composer payload and post API write. |
| Discover screen is empty | Create posts with hashtags and deploy required indexes. |
| Different casing creates duplicates | Normalize tags before writing indexes. |
| Feed query needs an index | Create the Firestore index from the error link or deploy indexes. |
| Blocked content still appears | Add cleanup logic and rules for hidden/deleted posts. |