◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
Articles/API / SDK
◈ API / SDK/2026-05-15Advanced

Building an AI Chat App with Expo and Gemini API: From First Commit to App Store Approval

An implementation record of shipping an Expo + Gemini API chat app through both store reviews — measured streaming latency, the chunk-boundary JSON bug, image payload limits, cost ceilings, and the pre-release checklist I run.

exporeact-nativegemini-api286indie-dev48iOS13Android12streaming28AI app

✦ Premium Article

The first time Gemini's response arrived one character at a time in my Expo chat view, I stopped and just watched it. Getting there had taken three days.

When I set out to integrate the Gemini API into a React Native app, I expected the process to be straightforward. It wasn't.

The streaming implementation alone took me the better part of two days to get right. The issue wasn't the Gemini API itself — the documentation is solid. The problem is that React Native's JavaScript environment behaves differently from a browser or Node.js, and the examples in the official docs are written with those environments in mind.

This article is a practical implementation record. I'll cover the parts that actually caused friction: streaming in Hermes, managing chat history without blowing up your token budget, handling image input, designing a freemium model that makes economic sense, and navigating the AI-specific requirements that App Store and Google Play reviewers will flag.

Why Expo, and What You Need to Know About Its Limits

For indie developers shipping to both iOS and Android, Expo's managed workflow is the right default choice. You avoid dealing with Xcode configuration drift, native module linking headaches, and platform-specific build systems. EAS Build handles the pipeline.

Where Expo's managed workflow gets constrained is around native APIs. For Gemini API integration, this matters in two places:

  • Camera and image library access: handled through expo-image-picker — no native code required
  • Audio input: handled through expo-av, though Live API integration requires more setup

The JavaScript engine is Hermes, which has its own quirks around async iterators and stream APIs. This is the root cause of the streaming problems I'll describe next.

I'm using Expo SDK 53 with @google/genai SDK 1.x. If you're on an older SDK version, upgrade first — streaming behavior changed significantly between SDK 51 and 52.

Setting Up the Gemini API Client

Installation:

npx create-expo-app my-ai-app --template blank-typescript
cd my-ai-app
npx expo install @google/genai expo-image-picker @react-native-async-storage/async-storage

API key management matters from day one. Hardcoding your key in source code is one GitHub push away from being scraped and abused. In React Native, there are two sensible approaches:

  1. Server-side proxy: Your app calls your own backend, which calls Gemini. The API key never leaves your server. Best for production.
  2. expo-secure-store: Encrypts the key at rest on the device. Acceptable for early testing; still exposes the key if someone reverse-engineers your app.

For development, use environment variables with the EXPO_PUBLIC_ prefix:

// lib/gemini.ts
import { GoogleGenAI } from "@google/genai";
 
const API_KEY = process.env.EXPO_PUBLIC_GEMINI_API_KEY ?? "";
 
if (!API_KEY) {
  throw new Error(
    "GEMINI_API_KEY is not set. Check your .env.local file."
  );
}
 
export const genAI = new GoogleGenAI({ apiKey: API_KEY });

.env.local:

EXPO_PUBLIC_GEMINI_API_KEY=YOUR_GEMINI_API_KEY
✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Measured latency across three streaming approaches, and where perception diverges from total time
✦A buffering parser that survives JSON split across chunk boundaries
✦An eight-item pre-release checklist covering review, cost, and failure modes
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

◈ API / SDK2026-07-03
Building AI-Powered iOS and Android Apps with the Gemini API — Image Recognition, Voice Analysis, Chat, and Monetization
Architecture patterns, cost optimization, and monetization for adding image recognition, voice analysis, and AI chat to iOS/Android apps with the Gemini API — updated with Gemma 4 routing and the mandatory API key restriction change.
◈ API / SDK2026-05-13
Maximizing Revenue in Indie iOS Wallpaper Apps with AdMob + Gemini API
A decade of indie app development reveals how to balance AdMob revenue against Gemini API costs. Learn architecture patterns, cost control strategies, and Freemium gate implementation for AI-powered wallpaper apps.
⟐ Dev Tools2026-03-31
Gemini API × React Native Operational Notes — Indie Mobile App in Production
Operational notes from running Gemini API inside a React Native/Expo indie mobile app on iOS and Android: real device pitfalls, AdMob coexistence, Cold Start mitigation, AsyncStorage TTL design, and cost realities at 65,000 monthly requests