0.3.2 • Published 2 years ago

@vulppi/react-use-firebase v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vulppi React Hooks for firebase

useFirestoreDoc

const Component: React.FC = () => {
  const { data, ref, snap, loading } = useFirestoreDoc<DocType>(
    'collection/doc-id',
    {
      block: false,
      dependencies: ['foo'],
      parser: (data) => data,
      fallback: {}, // default value in data
    },
  )

  return <></>
}

useFirestoreCollection

const Component: React.FC = () => {
  const { data, ref, snap, loading } = useFirestoreCollection<DocType>(
    'collection',
    {
      block: false,
      dependencies: ['foo'],
      parser: (data) => data,
      fallback: [], // default value in data
      filter: (ref) =>
        query(ref, where('createdAt', '<=', new Date()), limit(10)),
    },
  )

  return <></>
}

CLient side functions (firebase)

Load client service

import { createFirebaseClientService } from '@vulppi/use-firebase/client'

export const { app, db, auth } = createFirebaseClientService(
  firebaseClientCredentials,
)

Server side functions (firebase-admin)

Load static contents

import { createFirebaseAdminApp } from '@vulppi/use-firebase/admin'

export const { app, db, auth, getStaticContent, getStaticContents } =
  createFirebaseAdminApp(firebaseAdminCredentials)

// using

const snapDoc = getStaticContent<DocType>('collection', 'doc-id')
const snapCollection = getStaticContents('collection', (query) =>
  query.where('createdAt', '>=', new Date()).limit(10),
)

Update custom claims for users

claims in firestore collection users/{uid}/claims

const test = await handleRefreshClaims(FirebaseAdminApp, 'uid')
0.3.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.4

2 years ago

0.2.1

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.2

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago