H
Hono4mo ago
Prosigoj

Route types for client

I found an example that gives the hc client route types
const app = new Hono();

const routes = app.get("/api/clock", (c) => {
return c.json({
time: new Date().toLocaleTimeString(),
});
});

export type AppType = typeof routes;
const app = new Hono();

const routes = app.get("/api/clock", (c) => {
return c.json({
time: new Date().toLocaleTimeString(),
});
});

export type AppType = typeof routes;
but how would that look like if I had more routes?
11 Replies
Prosigoj
ProsigojOP4mo ago
I just saw hono/client is deprecated...
Arjix
Arjix4mo ago
Where did you see such information? Because it is 100% bullshit You can chain everything together
Prosigoj
ProsigojOP4mo ago
npm
@hono/client
HTTP Client for Hono. Latest version: 0.0.3, last published: 2 years ago. Start using @hono/client in your project by running npm i @hono/client. There is 1 other project in the npm registry using @hono/client.
Prosigoj
ProsigojOP4mo ago
just saw there is a newer one
Arjix
Arjix4mo ago
That is 2 years old Why were you even looking at it?
Prosigoj
ProsigojOP4mo ago
google spit it out
Arjix
Arjix4mo ago
Well the docs say otherwise
Prosigoj
ProsigojOP4mo ago
I searched for client in the docs wasn't able to find anything
Arjix
Arjix4mo ago
It's called RPC In the docs
Prosigoj
ProsigojOP4mo ago
ohh thanks
Arjix
Arjix4mo ago
np I can see the confusion Anyways, to answer ur original question, just chain everything together
const app = new Hono()
.get(...)
.post(....)

export type AppType = typeof app;
const app = new Hono()
.get(...)
.post(....)

export type AppType = typeof app;

Did you find this page helpful?