-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tips for rpc perf #490
Tips for rpc perf #490
Conversation
docs/guides/rpc.md
Outdated
|
||
However, we have some tips to mitigate this issue. | ||
|
||
#### compile your app before using it (recommended) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write the specific instructions for using d.ts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
Hey @m-shaka Good descriptions! These are needed. I've left a comment. Check it. |
I'm not sure this will help you, but I've created the repo to use |
Great! |
Hey. This is another approach in which @nakasyou tried similar things. https://github.com/yusukebe/hono-rpc-with-d-ts/tree/client-types In this branch, |
Oooops. Please ignore the CI is failing. |
Oh, I see. // server/client.ts
import routes from './server'
import { hc } from 'hono/client'
type Routes = typeof routes
export const getClient: typeof hc<Routes> = (...args) => hc<Routes>(...args)
// client/client.ts
import { getClient } from '../dist/client'
const client = getClient('http://localhost:3000')
const res = await client.index.$get()
const data = await res.json()
console.log(data) |
Some tricks are needed to calculate types on compiling. // server/client.ts
import routes from './server'
import { hc } from 'hono/client'
type Routes = typeof routes
const client = hc<Routes>('http://localhost:3000')
export type Client = typeof client
export const getClient = (...args: Parameters<typeof hc<Routes>>): Client =>
hc<Routes>(...args) |
Ah, cool! It's nitpicky, but how about renaming |
@nakasyou any thoughts on it? |
It looks cool! And I like |
Thank you, both of you! I revised the doc |
Hi @m-shaka I've updated the format of the docs and added a super short description for the |
Added tips to improve IDE performance when using RPC