Skip to main content
Typesafe ODM for Firestore - A lightweight wrapper that adds type safety and schema validation to your Firestore database operations in TypeScript. npm version License: MIT Firetype extends the existing Firestore SDK functionality while maintaining all its native features and requiring the original SDK to be installed. It provides a folder-based schema definition system that automatically generates fully type-safe APIs for your Firestore collections and documents.
⚠️ Important: Firetype extends the Firestore SDK and is not a replacement. You’ll still need to install and use either firebase-admin or firebase/firestore as your primary SDK.

✨ Features

  • 🎯 Full Type Safety: Complete TypeScript type inference for all Firestore operations with zero runtime overhead
  • 📁 Folder-Based Schema: Organize your database structure naturally in directories, including nested collections
  • 🔄 Runtime Validation: Optional Zod-powered schema validation with detailed error messages
  • 🛠️ Powerful CLI: Generate type definitions with flexible configuration options
  • SDK Agnostic: Works seamlessly with both firebase-admin and firebase/firestore SDKs
  • 🔗 Nested Collections: Full support for subcollections with automatic path generation
  • 📊 Collection Groups: Type-safe collection group queries across all subcollections
  • 🎨 Zero Config: Just define your schemas and let Firetype handle the rest

📦 Installation

Install Firetype using your preferred package manager:

Peer Dependencies

Firetype requires one of the following Firestore SDKs (choose based on your environment):
💡 Tip: Firetype works with both SDKs simultaneously if you need to support both client and server environments.

🚀 Quick Start

Get started with Firetype in 5 minutes. This guide shows you how to set up type-safe Firestore operations.

1. Set up your schema directory

Create a directory structure for your Firestore database schemas:

2. Define your first collection schema

Create schemas/database/users/schema.ts:

3. Generate type definitions

Use the Firetype CLI to generate your types:
This creates an index.ts file in your input folder with your fully typed Firestore API.

4. Use in your application

Server-side (Admin SDK)

Client-side (Web SDK)

5. Add subcollections (Optional)

Create nested collections by adding subdirectories. For user comments: schemas/database/users/comments/schema.ts:
Now you can access nested collections:

📚 Documentation Sections

Schema Definition

Learn how to define your Firestore schemas with Zod

CLI Reference

Complete guide to the Firetype command-line interface

API Reference

Detailed API documentation with examples

Examples

Real-world usage examples and patterns

🆘 Need Help?

Troubleshooting

Common issues and their solutions