Skip to main content
RapidDev - Software Development Agency
flutterflow-tutorials

How to Build a Social Media Aggregator in FlutterFlow

Build a social media aggregator that connects to Twitter, Instagram, and YouTube APIs via Cloud Functions, normalizes posts into a unified social_posts Firestore collection, and displays them in a single feed. Each post card shows the platform badge, content preview, engagement count, and a link to the original. Users connect accounts through OAuth flows and can view cross-platform engagement analytics.

What you'll learn

  • How to connect external social media APIs via Cloud Functions in FlutterFlow
  • How to normalize multi-platform data into a unified Firestore collection
  • How to build a unified social feed with platform badges and engagement metrics
  • How to implement OAuth account connection flows for external platforms
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read30-40 minFlutterFlow Free+March 2026RapidDev Engineering Team
TL;DR

Build a social media aggregator that connects to Twitter, Instagram, and YouTube APIs via Cloud Functions, normalizes posts into a unified social_posts Firestore collection, and displays them in a single feed. Each post card shows the platform badge, content preview, engagement count, and a link to the original. Users connect accounts through OAuth flows and can view cross-platform engagement analytics.

Building a Unified Social Feed from Multiple Platforms

Managing multiple social media accounts means switching between apps constantly. This tutorial builds a single aggregated feed that pulls your posts from Twitter/X, Instagram, and YouTube into one view. Connect accounts via OAuth, fetch posts through Cloud Functions, and display everything in a unified timeline with engagement analytics.

Prerequisites

  • A FlutterFlow project with Firestore and authentication configured
  • API credentials for at least one social platform (Twitter API, Instagram Basic Display API, or YouTube Data API)
  • Cloud Functions environment set up for your project
  • Basic understanding of REST API calls and OAuth flows

Step-by-step guide

1

Design the Firestore data model for aggregated social posts

Create a social_posts collection with fields: userId (String), platform (String: 'twitter', 'instagram', 'youtube'), platformPostId (String, the original post ID), content (String, text or caption), mediaUrl (String, nullable), mediaType (String: 'image', 'video', 'text'), timestamp (Timestamp), engagementCount (Integer, likes + comments combined), postUrl (String, link to original post). Also create a connected_accounts collection with: userId, platform, accessToken (encrypted), refreshToken, tokenExpiry, platformUsername. This normalized schema lets you query all platforms in one feed.

Expected result: Firestore has social_posts for unified content and connected_accounts for OAuth token storage per platform.

2

Build Cloud Functions for OAuth account connection

Create three Cloud Functions for connecting social accounts. Each function initiates the OAuth flow: generate an auth URL with required scopes, redirect the user, and handle the callback to exchange the authorization code for access and refresh tokens. Store tokens in connected_accounts with the platform field. For Twitter use OAuth 2.0 PKCE, for Instagram use Instagram Basic Display API OAuth, for YouTube use Google OAuth with youtube.readonly scope. Encrypt access tokens before storing in Firestore using a server-side encryption key.

connectTwitter.js
1// Cloud Function: connectTwitter (simplified)
2const functions = require('firebase-functions');
3const admin = require('firebase-admin');
4const crypto = require('crypto');
5
6const ENCRYPT_KEY = process.env.TOKEN_ENCRYPT_KEY;
7
8function encrypt(text) {
9 const iv = crypto.randomBytes(16);
10 const cipher = crypto.createCipheriv(
11 'aes-256-cbc', Buffer.from(ENCRYPT_KEY), iv
12 );
13 let encrypted = cipher.update(text, 'utf8', 'hex');
14 encrypted += cipher.final('hex');
15 return iv.toString('hex') + ':' + encrypted;
16}
17
18exports.handleTwitterCallback = functions.https
19 .onRequest(async (req, res) => {
20 const { code, state } = req.query;
21 const userId = state; // passed during auth init
22 // Exchange code for tokens
23 const tokenRes = await fetch(
24 'https://api.twitter.com/2/oauth2/token',
25 { method: 'POST', body: new URLSearchParams({
26 grant_type: 'authorization_code',
27 code, redirect_uri: REDIRECT_URI,
28 client_id: CLIENT_ID,
29 code_verifier: STORED_VERIFIER
30 })}
31 );
32 const tokens = await tokenRes.json();
33 await admin.firestore()
34 .collection('connected_accounts').add({
35 userId, platform: 'twitter',
36 accessToken: encrypt(tokens.access_token),
37 refreshToken: encrypt(tokens.refresh_token),
38 tokenExpiry: Date.now() + tokens.expires_in * 1000,
39 platformUsername: tokens.screen_name
40 });
41 res.redirect('/account-connected?platform=twitter');
42 });

Expected result: Users can connect their Twitter, Instagram, and YouTube accounts via OAuth, with tokens stored encrypted in Firestore.

3

Create a Cloud Function to fetch and normalize posts from all platforms

Build a scheduled Cloud Function (runs every hour) that iterates through connected_accounts, decrypts tokens, calls each platform API to fetch recent posts, and normalizes them into social_posts documents. For Twitter: GET /2/users/:id/tweets. For Instagram: GET /me/media. For YouTube: GET /youtube/v3/search?forMine=true. Map each response to the unified schema: extract content text, media URL, engagement metrics, and original post URL. Use platformPostId to avoid duplicate entries on subsequent fetches.

Expected result: Cloud Function periodically fetches posts from all connected platforms and writes normalized documents to social_posts.

4

Build the unified feed page with platform badges

Create an AggregatedFeedPage. Add a TabBar at the top with tabs: All, Twitter, Instagram, YouTube. Below, add a ListView with a Backend Query on social_posts filtered by userId equals current user, ordered by timestamp descending. For the 'All' tab, show all platforms. For individual tabs, add a where clause on platform. Each list item is a PostCard Container: a Row with a platform badge icon (bird for Twitter, camera for Instagram, play button for YouTube) using conditional Image based on the platform field, followed by a Column with content Text (truncated to 2 lines), mediaUrl as Image if present, engagementCount with a heart icon, and timestamp as relative time.

Expected result: A unified feed displays posts from all connected platforms with filterable tabs and platform-specific badges.

5

Add engagement analytics with cross-platform comparison

Create an AnalyticsPage accessible from a chart icon in the AppBar. Query social_posts grouped by platform and sum engagementCount. Display a Custom Widget bar chart (using fl_chart) comparing total engagement across platforms. Below the chart, show stat cards: total posts per platform, average engagement per post, most engaging post with a link. Add a date range picker to filter analytics to specific periods. This helps users understand which platform drives the most engagement.

Expected result: An analytics page shows bar charts comparing engagement across Twitter, Instagram, and YouTube with summary statistics.

6

Implement the cross-posting feature to publish to multiple platforms

Add a ComposePostPage with a TextField for content, an optional image picker, and ChoiceChips for selecting target platforms (Twitter, Instagram, YouTube). On submit, call a Cloud Function that receives the content and selected platforms, decrypts each platform's tokens, and posts via their respective APIs. Twitter: POST /2/tweets. Instagram: requires Facebook Graph API media creation flow. YouTube: community posts or video descriptions. Show a success/failure status per platform in a results dialog after posting.

Expected result: Users compose a post once and publish it to all selected social media platforms simultaneously.

Complete working example

FlutterFlow Social Aggregator Setup
1FIRESTORE DATA MODEL:
2 social_posts/{postId}
3 userId: String
4 platform: 'twitter' | 'instagram' | 'youtube'
5 platformPostId: String (dedup key)
6 content: String
7 mediaUrl: String (nullable)
8 mediaType: 'image' | 'video' | 'text'
9 timestamp: Timestamp
10 engagementCount: Integer
11 postUrl: String (link to original)
12
13 connected_accounts/{accountId}
14 userId: String
15 platform: String
16 accessToken: String (encrypted)
17 refreshToken: String (encrypted)
18 tokenExpiry: Integer
19 platformUsername: String
20
21PAGE: AggregatedFeedPage
22 WIDGET TREE:
23 Column
24 TabBar (All | Twitter | Instagram | YouTube)
25 Expanded
26 ListView
27 Backend Query: social_posts
28 where userId == currentUser.uid
29 where platform == selectedTab (if not All)
30 order by timestamp desc
31 Generate Dynamic Children PostCard
32
33 PostCard Container:
34 Row
35 Image (platform badge: conditional on platform field)
36 Column
37 Text (content, maxLines: 2)
38 Image (mediaUrl, if not null)
39 Row
40 Icon (heart) + Text (engagementCount)
41 Text (relative timestamp)
42 InkWell Launch URL (postUrl)
43
44PAGE: AnalyticsPage
45 WIDGET TREE:
46 Column
47 DateRangePicker
48 Custom Widget (fl_chart bar chart: engagement by platform)
49 Row (stat cards: posts count, avg engagement per platform)
50
51CLOUD FUNCTIONS:
52 1. connectTwitter / connectInstagram / connectYouTube (OAuth)
53 2. fetchSocialPosts (scheduled hourly, fetches + normalizes)
54 3. crossPost (posts content to selected platforms)

Common mistakes when building a Social Media Aggregator in FlutterFlow

Why it's a problem: Storing social platform access tokens unencrypted in Firestore

How to avoid: Encrypt tokens with a server-side key before storing. Decrypt only inside Cloud Functions when making API calls. Never expose tokens to the client.

Why it's a problem: Fetching posts from APIs on every page load instead of caching

How to avoid: Use a scheduled Cloud Function to fetch posts periodically (every hour) and store them in Firestore. The client reads cached data from Firestore.

Why it's a problem: Not handling expired OAuth tokens with automatic refresh

How to avoid: Check token expiry before each API call in the Cloud Function. If expired, use the refresh token to get a new access token and update Firestore.

Best practices

  • Encrypt all OAuth tokens before storing in Firestore and decrypt only in Cloud Functions
  • Use a scheduled Cloud Function to fetch posts periodically rather than on every page load
  • Deduplicate posts using platformPostId to prevent duplicates on repeated fetches
  • Implement automatic token refresh logic to handle expired access tokens silently
  • Normalize all platform data into a single schema for consistent UI rendering
  • Show platform badges on each post so users can quickly identify the source
  • Add rate limit handling with exponential backoff in Cloud Functions

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to build a social media aggregator in FlutterFlow that pulls posts from Twitter, Instagram, and YouTube into one feed. Show me the Firestore data model, OAuth Cloud Functions for connecting accounts, a scheduled fetch function that normalizes posts, and the FlutterFlow page layout with platform badges and engagement analytics.

FlutterFlow Prompt

Create a page with a tab bar at the top with four tabs: All, Twitter, Instagram, YouTube. Below add a list view for social post cards. Each card should have a row with a small icon image on the left and a column with text content and engagement count on the right.

Frequently asked questions

Which social media APIs are free to use?

YouTube Data API offers 10,000 quota units per day free. Instagram Basic Display API is free with rate limits. Twitter API free tier allows 1,500 tweets per month for reading. For higher volumes, paid tiers are required.

Can I add more platforms like TikTok or LinkedIn?

Yes. Add a new Cloud Function for OAuth connection, implement the fetch logic for that platform's API, and normalize the response into the same social_posts schema. The unified feed displays it automatically.

How do I handle rate limits from social media APIs?

Implement exponential backoff in Cloud Functions. If an API returns a 429 rate limit error, wait and retry with increasing delays. Also spread fetches across users to avoid hitting limits for all accounts simultaneously.

Is it safe to store OAuth tokens in Firestore?

Only if encrypted with a server-side key. Never store plain-text tokens. Decrypt only inside Cloud Functions when making API calls. Also implement Firestore Security Rules so only the Cloud Function service account can read connected_accounts.

Can users disconnect a social account?

Yes. Add a Disconnect button per platform that deletes the connected_accounts document and optionally deletes cached social_posts for that platform. Also revoke the OAuth token via the platform's revoke endpoint.

Can RapidDev help build a social media aggregator with advanced features?

Yes. RapidDev can implement multi-platform OAuth, automated content fetching, sentiment analysis, scheduling tools, and detailed engagement dashboards tailored to your specific needs.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.