v1.4.6
Summary
Now, JSX MIddleware is available! You can write JSX for rendering HTML.
import { Hono } from 'hono'
import { h, jsx } from 'hono/jsx'
export const app = new Hono()
app.use('*', jsx())
const Layout = (props: { children?: string }) => {
return (
<html>
<body>{props.children}</body>
</html>
)
}
const Top = (props: { message: string }) => {
return (
<Layout>
<h1>{props.message}</h1>
</Layout>
)
}
app.get('/', (c) => {
const message = 'Hello! Hono!!'
return c.render(<Top message={message} />)
})
export default app
tsconfig.json
{
"compilerOptions": {
"jsx": "react",
"jsxFactory": "h"
}
}
Enjoy!
What's Changed
- feat:
notFound
support asyc/await by @yusukebe in #303 - Update README.md by @charl-kruger in #304
- Export
md5
function in src/utils/crypto.ts by @erhlee-bird in #305 - perf(utils/html): Improve performance
escape()
by @usualoma in #307 - feat(middleware/jsx): Support dangerouslySetInnerHTML and some special spec by @usualoma in #308
- feat(middleware/jsx): Introduce memo. by @usualoma in #309
- feat: jsx middleware by @yusukebe in #306
New Contributors
- @erhlee-bird made their first contribution in #305
Full Changelog: v1.4.5...v1.4.6