M

Master Firebase Suite

Streamline your workflow with this firebase, gives, complete, backend. Includes structured workflows, validation checks, and reusable patterns for development.

SkillClipticsdevelopmentv1.0.0MIT
0 views0 copies

Firebase Development Skill

A Claude Code skill for building applications with the Firebase platform — covering Authentication, Firestore, Cloud Functions, Storage, Hosting, and real-time data synchronization patterns.

When to Use This Skill

Choose this skill when:

  • Building applications with Firebase as the backend
  • Implementing authentication with Firebase Auth (email, social, phone)
  • Designing Firestore data models and security rules
  • Writing Cloud Functions for server-side logic
  • Setting up real-time data listeners and offline persistence
  • Configuring Firebase Hosting with custom domains

Consider alternatives when:

  • You need a relational database (use PostgreSQL/MySQL)
  • You need complex server-side logic (use a traditional backend)
  • You need fine-grained access control beyond Firestore rules (use a custom auth service)

Quick Start

# Install Firebase tools npm install firebase firebase-admin npm install -g firebase-tools # Initialize Firebase in your project firebase init # Start local emulators for development firebase emulators:start
// Initialize Firebase client import { initializeApp } from 'firebase/app'; import { getFirestore, collection, doc, setDoc, onSnapshot } from 'firebase/firestore'; import { getAuth, signInWithEmailAndPassword } from 'firebase/auth'; const app = initializeApp({ apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY, authDomain: 'myapp.firebaseapp.com', projectId: 'myapp', storageBucket: 'myapp.appspot.com', }); const db = getFirestore(app); const auth = getAuth(app);

Core Concepts

Firebase Services

ServicePurposeUse Case
AuthUser authenticationSign-in, sign-up, social login, phone auth
FirestoreNoSQL document databaseReal-time data, offline support
Cloud FunctionsServerless backendTriggers, API endpoints, background jobs
StorageFile storageUser uploads, images, documents
HostingWeb hostingStatic sites, SPAs, SSR with Cloud Functions
FCMPush notificationsMobile and web push messages

Firestore Data Modeling

// Document structure for a project management app // /users/{userId} interface User { name: string; email: string; photoURL: string; createdAt: Timestamp; } // /organizations/{orgId} interface Organization { name: string; ownerId: string; memberIds: string[]; // Denormalized for queries } // /organizations/{orgId}/projects/{projectId} interface Project { name: string; status: 'active' | 'archived'; createdBy: string; createdAt: Timestamp; } // Real-time listener const unsubscribe = onSnapshot( collection(db, 'organizations', orgId, 'projects'), (snapshot) => { const projects = snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() })); setProjects(projects); } );

Firestore Security Rules

rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /users/{userId} { allow read: if request.auth != null; allow write: if request.auth.uid == userId; } match /organizations/{orgId} { allow read: if request.auth.uid in resource.data.memberIds; allow write: if request.auth.uid == resource.data.ownerId; match /projects/{projectId} { allow read: if request.auth.uid in get(/databases/$(database)/documents/organizations/$(orgId)).data.memberIds; allow create: if request.auth.uid in get(/databases/$(database)/documents/organizations/$(orgId)).data.memberIds; } } } }

Configuration

ParameterTypeDefaultDescription
project_idstringFirebase project ID (required)
use_emulatorsbooleantrueUse local emulators in development
emulator_portsobject{ auth: 9099, firestore: 8080 }Emulator port configuration
regionstring"us-central1"Cloud Functions deployment region
offline_persistencebooleantrueEnable Firestore offline cache
multi_tab_persistencebooleanfalseEnable multi-tab Firestore sync
storage_rulesstring"storage.rules"Path to Storage security rules

Best Practices

  1. Design Firestore data for your queries, not your entities — Firestore doesn't support joins; denormalize data into the document structure that matches how you read it, even if that means duplicating some fields.

  2. Always develop with Firebase emulators — the emulator suite provides local versions of Auth, Firestore, Functions, and Storage; this prevents accidental production writes and lets you test without network latency.

  3. Write security rules before deploying — Firestore and Storage are open by default in test mode; deploy rules that enforce authentication and authorization before any real user touches the app.

  4. Use batched writes for multi-document operations — Firestore batch writes are atomic (all succeed or all fail); use them when creating related documents that must be consistent.

  5. Keep Cloud Functions small and focused — each function should do one thing; large functions are slower to cold-start, harder to debug, and more expensive to run.

Common Issues

Firestore reads are expensive on nested data — Each document read is billed; reading a parent document doesn't include subcollections. Denormalize frequently-accessed child data into the parent document to reduce reads.

Cloud Functions cold start is slow — First invocations after idle periods take 5-10 seconds. Minimize dependencies, use minInstances: 1 for critical functions, and keep function packages small.

Security rules block legitimate requests — Rules are deny-by-default. Use the Firebase console's Rules Playground to test rules with specific user contexts before deploying, and check request.auth structure carefully.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates