Framework

Seed React Native + Firebase Apps with MockHero

The Setup

React Native app using Firebase JS SDK (or Reanimated + Firestore). A seed script populates Firestore so your Expo build loads with realistic data.

// scripts/seed.mjs
import { initializeApp, cert } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";

initializeApp({ credential: cert("./service-account.json") });
const db = getFirestore();

const data = await fetch("https://api.mockhero.dev/api/v1/generate", {
  method: "POST",
  headers: { "x-api-key": process.env.MOCKHERO_API_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    tables: [
      { name: "users", count: 50, fields: [
        { name: "id", type: "uuid" },
        { name: "name", type: "full_name" },
        { name: "avatar", type: "avatar_url" }
      ]},
      { name: "messages", count: 300, fields: [
        { name: "id", type: "uuid" },
        { name: "from", type: "ref", ref: "users.id" },
        { name: "body", type: "sentence" }
      ]}
    ]
  })
}).then(r => r.json());

const batch = db.batch();
for (const u of data.users) batch.set(db.collection("users").doc(u.id), u);
for (const m of data.messages) batch.set(db.collection("messages").doc(m.id), m);
await batch.commit();

Get Started

Free key here.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles