This document provides comprehensive context for AI coding assistants working with the react-firebase monorepo.
This is a TypeScript monorepo providing utilities for integrating Firebase with React and RxJS applications. The project delivers production-ready libraries for real-time data synchronization and state management.
react-firebase/
├── packages/
│ ├── react-firestore/ # React hooks for Firestore
│ ├── rxjs-firebase/ # RxJS utilities for Firebase
│ ├── react-query-observable/ # React Query + RxJS integration
│ ├── zustand-firestore/ # Zustand stores for Firestore
│ └── react-kitchen-sink/ # Comprehensive package combining all utilities
└── (root configs)
@valian/react-firestore
- React hooks for Firestore integration
- Main exports:
useCollection,useDocument - Handles real-time updates and loading states
- TypeScript-first with full type inference
@valian/rxjs-firebase
- RxJS operators and observables for Firebase
- Main exports:
fromQuery,fromDocumentRef,authState, state operators - Provides reactive streams for Firestore and Auth
- Advanced state management with subjects
@valian/react-query-observable
- Bridge between React Query and RxJS observables
- Main exports:
observableQueryOptions,observableQueryFn - Enables using observables as React Query data sources
- Seamless integration with TanStack Query
@valian/zustand-firestore
- Zustand store integration for Firestore
- State management for Firestore queries and documents
- Built on top of rxjs-firebase
- React hooks for Zustand stores with Firestore
@valian/react-kitchen-sink
- Comprehensive package combining all utilities
- Includes: React Query integration, Zustand stores, RxJS subjects
- Additional features: Sentry error tracking, Zod schema validation
- Advanced: Schema-based Firestore converters, error handling utilities
- One-stop solution for complex Firebase + React applications
- Build System: Nx 21.4.1 monorepo orchestration
- Package Manager: pnpm with workspaces
- Language: TypeScript (strict mode)
- Testing: Jest for unit tests
- Linting: ESLint + Prettier
- CI/CD: GitHub Actions
- Versioning: Conventional commits with semantic versioning
- Node.js (check
.nvmrcorpackage.jsonengines) - pnpm (specified in
package.jsonpackageManager field)
pnpm install # Install all dependencies
pnpm type-check # Verify TypeScript compilation
pnpm test # Run all testsRun these from the repository root:
pnpm eslint- Lint all packages with ESLintpnpm prettier- Check code formatting across the monorepopnpm lint:md- Lint all Markdown filespnpm test- Run all tests for all packagespnpm type-check- Type-check all TypeScript files
nx graph # Visualize project dependencies
nx run-many --target=build --all # Build all packages
nx affected --target=test # Test affected projects- TypeScript: All code must be TypeScript with strict type checking
- No
any: Use proper types orunknownwith type guards - Naming: Follow conventions in
.cursor/rules/naming-conventions-rule.mdc - Formatting: Code is auto-formatted with Prettier (see
.prettierrc)
- All new features require tests
- Test files:
*.test.tsor*.spec.ts - Use Jest for unit tests
- See
.cursor/rules/tests.mdcfor testing guidelines - Aim for high coverage on public APIs
- Follow Conventional Commits specification
- Format:
type(scope): description - Types:
feat,fix,docs,style,refactor,test,chore - Example:
feat(react-firestore): add useCollectionGroup hook
- CI checks must pass (linting, tests, type-check)
- Commitlint validates commit messages
- GitHub Actions workflows in
.github/workflows/
The monorepo follows a layered architecture:
Foundation Layer: rxjs-firebase
- Core RxJS utilities for Firebase
- No dependencies on other workspace packages
- Pure reactive programming patterns
- Base for all other packages
Integration Layer
react-firestore- Direct React hooks (minimal dependencies)react-query-observable- React Query + RxJS bridge (no workspace deps)zustand-firestore- Zustand stores (depends on rxjs-firebase)
Comprehensive Layer: react-kitchen-sink
- Combines all packages above
- Adds Sentry integration, Zod validation
- Production-ready batteries-included solution
- Hooks manage subscriptions and cleanup automatically
- Return objects with
{ data, loading, error }pattern - Handle Firebase snapshot conversions internally
- Optimized for React component lifecycle
- Pure RxJS observables for reactive programming
- State operators transform snapshots to state objects
- Subjects for advanced state management scenarios
- Memory-efficient with proper cleanup
- Adapts RxJS observables to React Query's expectations
- Handles observable lifecycle within Query's caching system
- Enables powerful caching, refetching, and synchronization
- Zustand stores backed by Firestore real-time data
- Combines Zustand's simplicity with Firebase's real-time updates
- Hooks and context providers for easy React integration
nx.json- Nx workspace configurationpnpm-workspace.yaml- pnpm workspace definitionstsconfig.json- Root TypeScript configurationpackages/*/tsconfig.json- Package-specific TS configs.cursor/rules/*.mdc- Coding rules and conventions.github/workflows/- CI/CD automation
- Works with Firebase JS SDK v9+ (modular API)
- Requires initialized Firebase app instance
- Supports real-time listeners and one-time reads
- Handles snapshot conversions and data extraction
authStateobservable for auth state changes (rxjs-firebase)- Compatible with all Firebase Auth providers
- Reactive user state management
- Auth hooks available in react-kitchen-sink
- React Query: Observable-based query functions for caching and synchronization
- Zustand: Real-time Firestore data in Zustand stores
- Both integrate seamlessly with rxjs-firebase observables
- Zod schema integration with Firestore
- Type-safe data converters using zod-firebase
- Automatic validation of Firestore documents
- Schema-based queries and documents
- Sentry integration for Firebase operations
- Automatic error capture with context
- Custom error handling utilities
- Production-ready error monitoring
- Ensure all packages are built:
pnpm -r build - Check TypeScript version consistency across packages
- Verify Firebase SDK types are installed
- Check Firebase mocks are properly configured
- Ensure test environment has required dependencies
- Review test isolation and cleanup
- Clear node_modules and reinstall:
rm -rf node_modules && pnpm install - Clear Nx cache:
nx reset - Check for circular dependencies
packages/react-firestore/AGENTS.md- React hooks for Firestorepackages/rxjs-firebase/AGENTS.md- RxJS utilities for Firebasepackages/react-query-observable/- React Query + RxJS integrationpackages/zustand-firestore/- Zustand stores for Firestorepackages/react-kitchen-sink/- Comprehensive utilities package
- Firebase Documentation: https://firebase.google.com/docs
- RxJS Documentation: https://rxjs.dev
- React Documentation: https://react.dev
- TanStack Query: https://tanstack.com/query
- Zustand: https://zustand-demo.pmnd.rs/
- This is an active monorepo with strict typing and linting
- Always use pnpm, never npm or yarn
- Respect conventional commits format
- Check Nx workspace rules before suggesting architecture changes
- Consider all 5 packages when making cross-cutting changes
- Test changes in relevant package contexts
react-kitchen-sinkdepends on all other packages - changes to core packages may affect it- Package dependency order:
rxjs-firebase→react-firestore/react-query-observable/zustand-firestore→react-kitchen-sink - Some packages have peer dependencies (React Query, Zustand, Sentry, Zod) - be aware of version compatibility
- When running tasks (for example build, lint, test, e2e, etc.), always prefer running the task through
nx(i.e.nx run,nx run-many,nx affected) instead of using the underlying tooling directly - You have access to the Nx MCP server and its tools, use them to help the user
- When answering questions about the repository, use the
nx_workspacetool first to gain an understanding of the workspace architecture where applicable. - When working in individual projects, use the
nx_project_detailsmcp tool to analyze and understand the specific project structure and dependencies - For questions around nx configuration, best practices or if you're unsure, use the
nx_docstool to get relevant, up-to-date docs. Always use this instead of assuming things about nx configuration - If the user needs help with an Nx configuration or project graph error, use the
nx_workspacetool to get any errors