github honojs/hono v1.4.6

latest releases: v4.3.9, v4.3.8, v4.3.7...
23 months ago

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

New Contributors

Full Changelog: v1.4.5...v1.4.6

Don't miss a new hono release

NewReleases is sending notifications on new releases.