-
|
Hi! I’m probably missing something obvious, but I’m not sure how to actually use client components with Hono JSX. I built a small tool with a REST API using Hono, and now I’m adding a frontend to display the data. SSR components are working fine, but I also need client-side interactivity. The docs include a page about client-side components (https://hono.dev/docs/guides/jsx-dom), but I don’t understand how to connect them with my existing API. For example, I tried rendering a component like this: Counter.tsximport { useState } from "hono/jsx";
export default function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}app.get("/", (c) => {
return c.render(
<div>
<Counter />
</div>,
);
});and also: app.get("/", (c) => {
return c.html(
<div>
<Counter />
</div>,
);
});In both cases, the response is just static HTML — the How do you properly wire up client components with the API so they actually run in the browser? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
This discussion might help you: https://github.com/orgs/honojs/discussions/2596 |
Beta Was this translation helpful? Give feedback.
This discussion might help you: https://github.com/orgs/honojs/discussions/2596