Skilllibrary react-native-firebase
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/08-web-frontend-and-design/react-native-firebase" ~/.claude/skills/merceralex397-collab-skilllibrary-react-native-firebase && rm -rf "$T"
manifest:
08-web-frontend-and-design/react-native-firebase/SKILL.mdsource content
Purpose
Integrate Firebase services (Auth, Firestore, FCM) with React Native using
@react-native-firebase for authentication, real-time data, and push notifications.
When to use this skill
- setting up
in a React Native project@react-native-firebase - implementing email/Google/Apple auth flows with Firebase Auth
- reading and writing Firestore data with real-time listeners
- configuring push notifications with Firebase Cloud Messaging
Do not use this skill when
- building a web-only app with Firebase — use Firebase JS SDK patterns
- using a non-Firebase backend (Supabase, Amplify) — different APIs
- the task is React Native UI without Firebase — prefer
react-typescript
Procedure
- Install packages —
.npx expo install @react-native-firebase/app @react-native-firebase/auth @react-native-firebase/firestore - Configure native — add
(Android) andgoogle-services.json
(iOS) to native project dirs.GoogleService-Info.plist - Set up Auth — use
,auth().signInWithEmailAndPassword()
. Listen withauth().createUserWithEmailAndPassword()
.auth().onAuthStateChanged() - Set up Firestore — read with
. Write withfirestore().collection('users').doc(uid).get()
or.set()
..update() - Add real-time listeners —
. Clean up infirestore().collection('messages').orderBy('createdAt').onSnapshot(snap => ...)
return.useEffect - Configure FCM — request permission with
. Get token:messaging().requestPermission()
. Handle withmessaging().getToken()
.messaging().onMessage() - Security rules — write Firestore rules that check
. Test with Firebase Emulator.request.auth.uid - Test offline — Firestore has offline persistence by default. Verify reads work without network.
Auth flow
import auth from '@react-native-firebase/auth'; import { useEffect, useState } from 'react'; function useAuth() { const [user, setUser] = useState(auth().currentUser); useEffect(() => { return auth().onAuthStateChanged(setUser); }, []); return user; } async function signIn(email: string, password: string) { try { await auth().signInWithEmailAndPassword(email, password); } catch (err: any) { if (err.code === 'auth/user-not-found') throw new Error('No account found'); if (err.code === 'auth/wrong-password') throw new Error('Incorrect password'); throw err; } }
Firestore patterns
import firestore from '@react-native-firebase/firestore'; // Real-time listener with cleanup function useMessages(chatId: string) { const [messages, setMessages] = useState([]); useEffect(() => { const unsubscribe = firestore() .collection('chats').doc(chatId).collection('messages') .orderBy('createdAt', 'desc') .limit(50) .onSnapshot(snap => { setMessages(snap.docs.map(d => ({ id: d.id, ...d.data() }))); }); return unsubscribe; }, [chatId]); return messages; }
Decision rules
- Always unsubscribe from Firestore listeners in
cleanup — prevents memory leaks.useEffect - Use
as the single source of auth truth — not manual state.auth().onAuthStateChanged() - Structure Firestore as shallow collections — avoid deep nesting (max 1 subcollection level).
- Store FCM tokens in Firestore under the user document — enables server-side push targeting.
- Test with Firebase Emulator Suite locally — do not test against production.
References
Related skills
— React component patternsreact-typescript
— client state alongside Firestorestate-management
— auth form validationforms-validation