@hyper-fetch/hono 10.0.0 โ†’ 10.1.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 +62 -38
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,39 +1,31 @@
1
- # ๐Ÿฏ Hyper Fetch Hono
1
+ <p align="center">
2
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/.github/assets/packages/hono.png" alt="Hyper Fetch Hono. Your Hono app. Typed on the client. Route, validator and param types read from typeof app with no codegen and no runtime." /></a>
3
+ </p>
2
4
 
3
5
  <p align="center">
4
- <b>Call your Hono backend from a fully typed HyperFetch SDK. No codegen, no duplicated types.</b>
6
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><b>Quick Start</b></a> ยท
7
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview">Documentation</a> ยท
8
+ <a href="https://hyperfetch.bettertyped.com/docs/api/hono/Types/HonoAppToHyperFetch">API Reference</a> ยท
9
+ <a href="https://github.com/BetterTyped/hyper-fetch">GitHub</a> ยท
10
+ <a href="https://discord.gg/7upC2kVmyM">Discord</a>
5
11
  </p>
6
12
 
7
13
  <p align="center">
8
- <a href="https://github.com/BetterTyped/hyper-fetch">
9
- <img src="https://img.shields.io/github/stars/BetterTyped/hyper-fetch?logo=github&color=118ab2" alt="GitHub stars" />
10
- </a>
11
- <a href="https://www.npmjs.com/package/@hyper-fetch/hono">
12
- <img src="https://img.shields.io/npm/v/@hyper-fetch/hono?logo=npm&color=e76f51" alt="npm version" />
13
- </a>
14
- <a href="https://www.npmjs.com/package/@hyper-fetch/hono">
15
- <img src="https://img.shields.io/npm/dm/@hyper-fetch/hono?logo=npm" alt="npm downloads" />
16
- </a>
17
- <a href="https://bundlephobia.com/package/@hyper-fetch/hono">
18
- <img src="https://img.shields.io/bundlephobia/minzip/@hyper-fetch/hono?color=64BC4B" alt="bundle size" />
19
- </a>
20
- <a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md">
21
- <img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch?color=yellow" alt="license" />
22
- </a>
23
- <a href="https://github.com/BetterTyped/hyper-fetch">
24
- <img src="https://img.shields.io/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" alt="TypeScript" />
25
- </a>
26
- <a href="https://hono.dev/">
27
- <img src="https://img.shields.io/badge/hono-E36002?logo=hono&logoColor=white" alt="Hono" />
28
- </a>
14
+ <a href="https://github.com/BetterTyped/hyper-fetch"><img src="https://img.shields.io/github/stars/BetterTyped/hyper-fetch?style=flat&logo=github&color=333" alt="GitHub stars" /></a>
15
+ <a href="https://www.npmjs.com/package/@hyper-fetch/hono"><img src="https://img.shields.io/npm/v/@hyper-fetch/hono?logo=npm&color=e76f51" alt="npm version" /></a>
16
+ <a href="https://www.npmjs.com/package/@hyper-fetch/hono"><img src="https://api.maciejpyrc.com/portfolio/npm/downloads.svg?packages=@hyper-fetch/hono&color=fbc646" alt="Monthly downloads" /></a>
17
+ <a href="https://bundlejs.com/?q=@hyper-fetch/hono"><img src="https://api.maciejpyrc.com/portfolio/npm/size.svg?package=@hyper-fetch/hono&external=@hyper-fetch/core,hono" alt="Bundle size" /></a>
18
+ <a href="https://github.com/BetterTyped/hyper-fetch"><img src="https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white" alt="TypeScript" /></a>
19
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><img src="https://img.shields.io/badge/Hono-4%2B-E36002?logo=hono&logoColor=white" alt="Hono" /></a>
20
+ <a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md"><img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch?color=blue" alt="License" /></a>
29
21
  </p>
30
22
 
31
23
  ## ๐Ÿ“– About
32
24
 
33
- `@hyper-fetch/hono` turns the type of a Hono app into a HyperFetch SDK schema. Your frontend calls the backend through
34
- `createSdk` with response, payload, query and param types read straight from your Hono routes and validators, and its
35
- sockets connect to `upgradeWebSocket()` and `streamSSE()` routes at type-checked paths. It ships types only, so nothing
36
- from your server ends up in the client bundle.
25
+ `@hyper-fetch/hono` turns the type of a Hono app into a Hyper Fetch SDK schema. Your frontend calls the backend
26
+ through `createSdk` with response, payload, query and param types read straight from your Hono routes and validators,
27
+ and its sockets connect to `upgradeWebSocket()` and `streamSSE()` routes at type-checked paths. It ships types only, so
28
+ nothing from your server ends up in the client bundle.
37
29
 
38
30
  ## ๐ŸŽฏ Key Capabilities
39
31
 
@@ -45,7 +37,7 @@ from your server ends up in the client bundle.
45
37
  - ๐Ÿ“ก **Realtime routes too** - `HonoWebSocketPath` rejects socket URLs that match no `upgradeWebSocket()` route
46
38
  - ๐Ÿšซ **No fake requests** - WebSocket routes stay out of the HTTP SDK, so nobody calls `send()` on them
47
39
  - ๐Ÿชถ **Zero runtime** - Type exports only, so it adds no code to your bundle
48
- - โšก **Every HyperFetch feature** - Cache, retries, deduplication, offline and React hooks work on every route
40
+ - โšก **Every HyperFetch feature** - Cache, retries, deduplication, offline replay and React hooks on every route
49
41
 
50
42
  ## ๐Ÿš€ Quick Start
51
43
 
@@ -71,15 +63,16 @@ import type { AppSchema } from "@my-app/backend";
71
63
  const client = createClient({ url: "https://api.example.com" });
72
64
  const sdk = createSdk<typeof client, AppSchema>(client);
73
65
 
66
+ // data is { id: string; name: string } | null
74
67
  const { data } = await sdk.users.$userId.$get.setParams({ userId: "1" }).send();
75
68
  ```
76
69
 
77
70
  ## ๐Ÿ“š Documentation
78
71
 
79
- - [Hono Integration Docs](https://hyperfetch.bettertyped.com/docs/integrations/hono/overview)
80
- - [Hono Realtime](https://hyperfetch.bettertyped.com/docs/integrations/hono/realtime)
81
- - [SDK Guide](https://hyperfetch.bettertyped.com/docs/core/sdk)
82
- - [Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)
72
+ - **[Hono Integration](https://hyperfetch.bettertyped.com/docs/integrations/hono/overview)** - Setup, routes, validators and path shapes
73
+ - **[Hono Realtime](https://hyperfetch.bettertyped.com/docs/integrations/hono/realtime)** - WebSocket and Server-Sent Events routes
74
+ - **[SDK](https://hyperfetch.bettertyped.com/docs/core/sdk)** - How `createSdk` turns a schema into requests
75
+ - **[API Reference](https://hyperfetch.bettertyped.com/docs/api/hono/Types/HonoAppToHyperFetch)** - Every exported type
83
76
 
84
77
  ## ๐Ÿ’ก Examples
85
78
 
@@ -108,7 +101,9 @@ export type AppSchema = HonoAppToHyperFetch<typeof app>;
108
101
  ```ts
109
102
  const sdk = createSdk<typeof client, AppSchema>(client);
110
103
 
104
+ // the payload is typed by the json validator
111
105
  await sdk.users.$post.setPayload({ name: "Bob" }).send();
106
+
112
107
  // kebab-case paths become camelCase properties: GET /auth/google-login
113
108
  await sdk.auth.googleLogin.$get.send();
114
109
  ```
@@ -123,7 +118,7 @@ import { sdk } from "./api";
123
118
  export const UserName = ({ userId }: { userId: string }) => {
124
119
  const { data, loading } = useFetch(sdk.users.$userId.$get.setParams({ userId }));
125
120
 
126
- if (loading) return <p>Loading...</p>;
121
+ if (loading) return <Spinner />;
127
122
  return <p>{data?.name}</p>;
128
123
  };
129
124
  ```
@@ -164,7 +159,7 @@ chat.message.$listener.listen(({ data }) => console.log(data.text));
164
159
  ### Server-Sent Events with named events
165
160
 
166
161
  ```ts
167
- // backend: named events reach the listeners of the event name, JSON data is parsed
162
+ // backend: named events reach the listeners of that event name, JSON data is parsed
168
163
  app.get("/events", (c) =>
169
164
  streamSSE(c, async (stream) => {
170
165
  await stream.writeSSE({ id: "1", event: "tick", data: JSON.stringify({ symbol: "BTC", price: 100 }) });
@@ -179,17 +174,46 @@ import { ServerSentEventsAdapter, Socket } from "@hyper-fetch/sockets";
179
174
 
180
175
  const events = new Socket({
181
176
  url: "http://localhost:3000/events",
182
- adapter: ServerSentEventsAdapter,
177
+ adapter: ServerSentEventsAdapter(),
183
178
  adapterOptions: { EventSource },
184
179
  });
185
180
 
186
181
  events
187
182
  .createListener<{ symbol: string; price: number }>()({ topic: "tick" })
188
- .listen(({ data }) => {
189
- console.log(data.price);
190
- });
183
+ .listen(({ data }) => console.log(data.price));
191
184
  ```
192
185
 
186
+ ## ๐Ÿงฉ Hyper Fetch Ecosystem
187
+
188
+ One typed client for every backend. Swap the adapter and keep the same `createRequest()` everywhere.
189
+
190
+ <table align="center">
191
+ <tr>
192
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/core"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-hyper-fetch.svg" width="36" height="36" alt="" /><br /><sub><b>Core</b></sub></a></td>
193
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/react"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-react.svg" width="36" height="36" alt="" /><br /><sub><b>React</b></sub></a></td>
194
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/sockets"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-sockets.svg" width="36" height="36" alt="" /><br /><sub><b>Sockets</b></sub></a></td>
195
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/cli"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-openapi.svg" width="36" height="36" alt="" /><br /><sub><b>OpenAPI CLI</b></sub></a></td>
196
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-graphql"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-graphql.svg" width="36" height="36" alt="" /><br /><sub><b>GraphQL</b></sub></a></td>
197
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-trpc"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-trpc.svg" width="36" height="36" alt="" /><br /><sub><b>tRPC</b></sub></a></td>
198
+ </tr>
199
+ <tr>
200
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-orpc"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-orpc-dark.svg" /><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-orpc.svg" width="36" height="36" alt="" /></picture><br /><sub><b>oRPC</b></sub></a></td>
201
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/hono"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-hono.svg" width="36" height="36" alt="" /><br /><sub><b>Hono</b></sub></a></td>
202
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/elysia"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-elysia.svg" width="36" height="36" alt="" /><br /><sub><b>Elysia</b></sub></a></td>
203
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-firebase"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-firebase.svg" width="36" height="36" alt="" /><br /><sub><b>Firebase</b></sub></a></td>
204
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-axios"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-axios.svg" width="36" height="36" alt="" /><br /><sub><b>Axios</b></sub></a></td>
205
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/hyper-flow"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/hyper-flow.svg" width="36" height="36" alt="" /><br /><sub><b>HyperFlow</b></sub></a></td>
206
+ </tr>
207
+ </table>
208
+
209
+ ## ๐Ÿ’– Sponsors
210
+
211
+ <p align="center">
212
+ <a href="https://github.com/sponsors/prc5">
213
+ <img src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/other/sponsorkit/sponsors.svg?raw=true" alt="Sponsors" />
214
+ </a>
215
+ </p>
216
+
193
217
  ## License
194
218
 
195
219
  [Apache-2.0](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/hono",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "description": "Turn a Hono app type into a fully typed Hyper Fetch SDK schema",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
6
  "homepage": "https://hyperfetch.bettertyped.com/",