npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

firestore-ts-repo

v0.5.0

Published

This is a simple repository for Firebase Firestore. It is written in TypeScript and uses the Firebase v10 SDK.

Readme

Firebase Firestore Repository for TypeScript

This is a simple repository for Firebase Firestore. It is written in TypeScript and uses the Firebase v10 SDK.

The main use case is to have a single place to define your collections and subcollections, and then use them throughout your app. This way you can make sure you are only using existing fields in your types, and get IDE help for your queries.

Installation

npm i firestore-ts-repo

API

export interface CollectionRepo<T> {
    // helper function to make sure you are only using existing fields in your type
    fieldName: FieldNames<T>
    // reference to the collection, for usage in queries updates etc.
    collection: CollectionReference<T>
    // reference to a document, for usage in queries updates etc.
    docRef: (id: string) => DocumentReference<T>
    // get the actual document
    doc: (id: string) => Promise<DocumentSnapshot<T>>
}

export interface SubCollectionRepo<T> {
    // helper function to make sure you are only using existing fields in your type
    fieldName: FieldNames<T>
    // reference to the collection, for usage in queries updates etc.
    collection: SubCollection<T>
    // enter the parent id to get a reference to the subcollection
    collectionById: (parentId: string) => CollectionReference<T>
    // reference to a document, for usage in queries updates etc.
    docRef: (parentId: string, id: string) => DocumentReference<T>
      // get the actual document
    doc: (parentId: string, id: string) => Promise<DocumentSnapshot<T>>
    // sometimes you need to query the subcollection without the parentId, this uses collectionGroup from Firestore
    collectionGroup: Query<T>
}

Usage

Import your types and the helper functions from the package:

import { type User, type Books } from './your/types';
import { type CollectionRepo, createCollectionRepo, createSubCollectionRepo, type SubCollectionRepo } from 'firestore-ts-repo'

Note: You also need to have your Firestore instance available.

Create a repo for your collection:

const userRepo: CollectionRepo<User> = createCollectionRepo<User>(firestore, 'users');

or for a subcollection:

const booksRepo: SubCollectionRepo<Books, User> = createSubCollectionRepo<Books>(firestore, 'users', 'books');

export your repo for the rest of your app to use

const repos = {
  users: userRepo,
  books: booksRepo
}

export default repos;

Then you can use the repo to do common Firestore operation, with strict typing and IDE help:

Query the collection

import repo from './your/repo';

// create a query for a specific type
const q = query<User>(
  // gets the collection reference from the repo
  repo.users.collection,
  // using the fieldName helper, makes sure you are only querying on existing fields in the User type
  where(repo.users.fieldName('displayName'), '==', 'test'),
)

Getting a document

import repo from './your/repo';

// reference to a document, for usage in queries updates etc.
const _ref: User = repo.users.docRef('some-user-id');

// or

// get the actual document
const user: User = repo.users.doc('some-user-id');

Getting a document from a subcollection

import repo from './your/repo';

// reference to a document, for usage in queries updates etc.
const _ref: Book = repo.books.doc('some-user-id', 'some-book-id');