How to use Async Server Component with honojs? #1552
-
Example: const AsyncComp = async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return <h1>Hello from async</h1>;
};
export default (c) => {
return c.html(
<div>
<AsyncComp />
</div>
)
} If I try to use this I have an error from ts:
But even if I run it I got the error in the console
jsx tsconfig is: Typescript version is: 5.2.2 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Any idea how to enable this like in nextjs? |
Beta Was this translation helpful? Give feedback.
-
I can't find that hono supports async server component. |
Beta Was this translation helpful? Give feedback.
-
Hi, If we decide to support async components, it won't happen immediately. And I think it's not as necessary as client-side JSX like React since you can write async procedures in the handler. I think if "jsxte" works well, you can use it. We can use any JSX libraries, not only Hono-JSX. |
Beta Was this translation helpful? Give feedback.
-
You can always do this as a workaround until the new PR is merged: async function Whatever(props: any) {
const thing = await getThing();
return <div>{thing}</div>;
}
async function WhateverWrapper() {
return <div>{await Whatever({ ...props })}</div>
} It's ugly but it works fine to do async components today |
Beta Was this translation helpful? Give feedback.
Hi,
If we decide to support async components, it won't happen immediately. And I think it's not as necessary as client-side JSX like React since you can write async procedures in the handler.
I think if "jsxte" works well, you can use it. We can use any JSX libraries, not only Hono-JSX.