H
Hono3mo ago
or

How to Achieve Full Type-Safe Communication Between a Hono Server and a Next.js Client in a Monorepo

I have a Hono server running on port 8787 and a Next.js client on port 3000. Both are in a monorepo. How can I achieve full type safety between them? I also want the requests to be written in a very professional way, for example: await api.users.$get() I’d appreciate code examples or explanations, thank you!
3 Replies
ambergristle
ambergristle3mo ago
you can generate the app type during transpilation + use Hono's RPC client to call from the front end https://hono.dev/docs/guides/rpc but if you're only using Next for the client, i'd recommend just using React. i'm not sure Next is worth the trouble if you're not using it full-stack
or
orOP3mo ago
I understand what you’re saying, but Next.js provides a lot of things built-in. The backend is intentionally separate because there might also be a native app in the future — isn’t that a smart approach?
ambergristle
ambergristle3mo ago
i'd really use react, but you do you

Did you find this page helpful?