@hyper-fetch/firebase 8.1.0 โ†’ 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +90 -32
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
- # ๐Ÿ”ฅ Hyper Fetch Firebase Web
1
+ # ๐Ÿ”ฅ Hyper Fetch Firebase
2
2
 
3
- <p>
3
+ <p align="center">
4
+ <b>Type-safe Firebase/Firestore client built on HyperFetch. CRUD, realtime listeners, auth โ€” all typed.</b>
5
+ </p>
6
+
7
+ <p align="center">
4
8
  <a href="https://bettertyped.com/">
5
9
  <img src="https://custom-icon-badges.demolab.com/static/v1?label=&message=BetterTyped&color=333&logo=BT" />
6
10
  </a>
@@ -13,58 +17,112 @@
13
17
  <a href="https://www.npmjs.com/package/@hyper-fetch/firebase">
14
18
  <img src="https://custom-icon-badges.demolab.com/npm/v/@hyper-fetch/firebase.svg?logo=npm&color=e76f51" />
15
19
  </a>
16
- <a href="https://github.com/BetterTyped/hyper-fetch">
17
- <img src="https://custom-icon-badges.demolab.com/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" />
20
+ <a href="https://www.npmjs.com/package/@hyper-fetch/firebase">
21
+ <img src="https://custom-icon-badges.demolab.com/npm/dm/@hyper-fetch/firebase?logoColor=fff&logo=trending-up" />
18
22
  </a>
19
23
  <a href="https://github.com/BetterTyped/hyper-fetch">
20
- <img src="https://custom-icon-badges.demolab.com/badge/-Firebase-E10098?logo=firebase&logoColor=white" />
24
+ <img src="https://custom-icon-badges.demolab.com/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" />
21
25
  </a>
22
- <a href="https://www.npmjs.com/package/@hyper-fetch/firebase">
26
+ <a href="https://bundlephobia.com/package/@hyper-fetch/firebase">
23
27
  <img src="https://custom-icon-badges.demolab.com/bundlephobia/minzip/@hyper-fetch/firebase?color=64BC4B&logo=package" />
24
28
  </a>
29
+ <a href="https://github.com/BetterTyped/hyper-fetch">
30
+ <img src="https://img.shields.io/badge/firebase-ffca28?logo=firebase&logoColor=black" alt="Firebase" />
31
+ </a>
25
32
  </p>
26
33
 
27
- ## About
34
+ ## ๐Ÿ“– About
35
+
36
+ This adapter brings HyperFetch's typed request system to Firebase. Use the same `createRequest` / `.send()` patterns for Firestore and Realtime Database operations with typed responses, caching, queuing, and React hooks โ€” the same API you use for REST.
37
+
38
+ ## ๐ŸŽฏ Key Capabilities
39
+
40
+ - ๐Ÿ”ฅ **Same API for Firebase** โ€” Use `createRequest` / `.send()` for Firestore and Realtime Database, just like REST
41
+ - ๐Ÿ”ฎ **Typed CRUD** โ€” `getDoc`, `addDoc`, `updateDoc`, `deleteDoc` with full TypeScript types on every field
42
+ - ๐Ÿ“ก **Realtime subscriptions** โ€” Listen to document and collection changes with typed data flowing in
43
+ - โš›๏ธ **React hooks for Firebase** โ€” `useFetch` and `useSubmit` work with Firebase operations โ€” same patterns, different backend
44
+ - ๐Ÿ’พ **Cache and offline support** โ€” HyperFetch's caching and offline queue work with Firebase out of the box
45
+
46
+ ## ๐Ÿš€ Quick Start
47
+
48
+ ```bash
49
+ npm install @hyper-fetch/core @hyper-fetch/firebase firebase
50
+ ```
51
+
52
+ ```ts
53
+ import { createClient } from "@hyper-fetch/core";
54
+ import { FirebaseAdapter } from "@hyper-fetch/firebase";
55
+ import { getFirestore } from "firebase/firestore";
56
+
57
+ const db = getFirestore();
58
+ const client = createClient({ url: "" }).setAdapter(FirebaseAdapter(db));
59
+ ```
60
+
61
+ ## ๐Ÿ“š Documentation
28
62
 
29
- **`Hyper Fetch Firebase`** is adapter for Hyper Fetch. Take advantage of the powerful features and simplicity of the
30
- first class Firebase adapter for **browser and server**, simplifying the retrieval and manipulation of data. Benefit
31
- from the convenience and efficiency of Hyper Fetch for your Firebase-powered projects.
63
+ - [Firebase Adapter Docs](https://hyperfetch.bettertyped.com/docs/integrations/adapter-firebase)
64
+ - [Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)
65
+ - [API Reference](https://hyperfetch.bettertyped.com/api/)
32
66
 
33
- ## Key Features
67
+ ## ๐Ÿ’ก Examples
34
68
 
35
- ๐Ÿ”ฎ **Simple setup** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/basic/setup)
69
+ ### Read a document
36
70
 
37
- ๐ŸŽฏ **Request cancellation** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/cancellation)
71
+ ```ts
72
+ interface User {
73
+ id: string;
74
+ name: string;
75
+ email: string;
76
+ }
38
77
 
39
- โœจ **Window Focus/Blur Events** -
40
- [Read more](https://hyperfetch.bettertyped.com/docs/guides/react/core/window-focus-blur)
78
+ const getUser = client.createRequest<{ response: User }>()({
79
+ endpoint: "/users/:userId",
80
+ method: "getDoc",
81
+ });
41
82
 
42
- ๐Ÿš€ **Queueing** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/queueing)
83
+ const { data } = await getUser.setParams({ userId: "abc123" }).send();
84
+ console.log(data.name, data.email);
85
+ ```
43
86
 
44
- ๐Ÿ’Ž **Automatic caching** - [Read more](https://hyperfetch.bettertyped.com/docs/core/cache)
87
+ ### Write a document
45
88
 
46
- ๐Ÿช„ **Persistence** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/persistence)
89
+ ```ts
90
+ const createUser = client.createRequest<{
91
+ payload: { name: string; email: string };
92
+ response: null;
93
+ }>()({
94
+ endpoint: "/users",
95
+ method: "addDoc",
96
+ });
47
97
 
48
- ๐ŸŽŠ **SSR Support** - [Read more](https://hyperfetch.bettertyped.com/docs/getting-started/environment)
98
+ await createUser.send({ data: { name: "Jane", email: "jane@example.com" } });
99
+ ```
49
100
 
50
- ๐Ÿ”‹ **Offline First** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/offline)
101
+ ### List documents
51
102
 
52
- ๐Ÿ“ก **Built-in adapter** - [Read more](https://hyperfetch.bettertyped.com/docs/core/adapter)
103
+ ```ts
104
+ const listUsers = client.createRequest<{ response: User[] }>()({
105
+ endpoint: "/users",
106
+ method: "getDocs",
107
+ });
53
108
 
54
- ๐Ÿงช **Easy to test** - [Read more](https://hyperfetch.bettertyped.com/docs/getting-started/testing)
109
+ const { data: users } = await listUsers.send();
110
+ users.forEach((user) => console.log(user.name));
111
+ ```
55
112
 
56
- ๐ŸŽŸ **Authentication** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/basic/authentication)
113
+ ### Use with React hooks
57
114
 
58
- ๐Ÿ’ก **Prefetching** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/prefetching)
115
+ ```tsx
116
+ import { useFetch } from "@hyper-fetch/react";
59
117
 
60
- ## Help me keep working on this project โค๏ธ
118
+ const UserProfile = ({ userId }: { userId: string }) => {
119
+ const { data, loading } = useFetch(getUser.setParams({ userId }));
61
120
 
62
- - [Become a Sponsor on GitHub](https://github.com/sponsors/prc5)
121
+ if (loading) return <p>Loading...</p>;
122
+ return <h1>{data?.name}</h1>;
123
+ };
124
+ ```
63
125
 
64
- ## Sources
126
+ ## License
65
127
 
66
- - #### [Installation](https://hyperfetch.bettertyped.com/docs/getting-started/installation)
67
- - #### [Docs](https://hyperfetch.bettertyped.com/docs/react/overview)
68
- - #### [API](https://hyperfetch.bettertyped.com/api/)
69
- - #### [NPM](https://www.npmjs.com/package/@hyper-fetch/firebase)
70
- - #### [Guides](https://hyperfetch.bettertyped.com/guides/basic/setup)
128
+ [MIT](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/firebase",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "description": "First class Firebase Web adapter for Hyper Fetch",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
6
  "homepage": "https://hyperfetch.bettertyped.com/",