Skip to content

Instantly share code, notes, and snippets.

@yusukebe
Created November 13, 2023 06:25
Show Gist options
  • Save yusukebe/a35e2d53c87cc28729c64e11a7f8386d to your computer and use it in GitHub Desktop.
Save yusukebe/a35e2d53c87cc28729c64e11a7f8386d to your computer and use it in GitHub Desktop.
import { Hono } from 'hono'
import { jsxRenderer } from 'hono/jsx-renderer'
import { Suspense } from 'hono/jsx/streaming'
const app = new Hono()
const Component = async () => {
const res = await fetch('https://ramen-api.dev/shops/yoshimuraya')
const data = await res.json<{ shop: { name: string } }>()
return <div>{data.shop.name} ๐Ÿœ</div>
}
app.get(
'*',
jsxRenderer(
({ children }) => {
return (
<html>
<body>{children}</body>
</html>
)
},
{
stream: true
}
)
)
app.get('/', (c) => {
return c.render(
<Suspense fallback={<div>loading...</div>}>
<Component />
</Suspense>
)
})
export default app
@yusukebe
Copy link
Author

How about using Chrome?

@nicanordlc
Copy link

Ooh, I just tried Chrome and it works great. It is a safari thing then ๐Ÿ˜…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment