Skip to content
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

docs: (RPC) add info about matching hono versions client-server #552

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

catalinpit
Copy link

Add information about using Hono RPC in projects where the client and server are in a single project. I spent way too much time wrestling with this before finding a comment online about the Hono version.

Add information about using Hono RPC in projects where the client and server are in a single project.
@catalinpit catalinpit changed the title Update rpc.md docs: (RPC) add info about matching hono versions client-server Dec 19, 2024
@yusukebe
Copy link
Member

Hi @catalinpit !

Thank you for the PR. This will be helpful.

I think we must add the description, not be in the Compile your code before using it (recommended) section. You can create a new section about it at the same level as Compile your code before using it (recommended):

CleanShot 2024-12-21 at 16 48 25@2x

Because the problem is not only when the code is being compiled; other problems will happen without compiling. For example, suppose you have monorepo, which includes one server application and one frontend. In that case, if the versions are different and, you use the exported type from the server app in the frontend, the editor throws the error like this:

CleanShot 2024-12-21 at 16 54 14@2x

Repro: https://github.com/yusukebe/hono-version-mismatch

This problem occurs not only due to a version mismatch but also when the paths to the hono files referenced by each project are different. However, in many cases, ensuring that the versions are the same can solve the problem.

@catalinpit
Copy link
Author

Hey @yusukebe, thanks for the reply and suggestion! I actually ran into that problem as well - Type instantiation is excessively deep and possibly infinite.

I'll add a new section!

@catalinpit
Copy link
Author

Done. Change made. 🙌

@@ -523,8 +533,6 @@ const res = await client.posts.$post({

If your project is a monorepo, this solution does fit well. Using a tool like [`turborepo`](https://turbo.build/repo/docs), you can easily separate the server project and the client project and get better integration managing dependencies between them. Here is [a working example](https://github.com/m-shaka/hono-rpc-perf-tips-example).

If your client and server are in a single project, [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) of `tsc` is a good option.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this line? I think it's OK to leave it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it above in its section #### TypeScript project references. Should I leave it here as well?

@yusukebe
Copy link
Member

@catalinpit

Sorry for the late response. I've added the comment!

@catalinpit
Copy link
Author

@catalinpit

Sorry for the late response. I've added the comment!

No worries. Thanks for the replies!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants