JSX middleware
See original GitHub issueWe want to have JSX middleware. This was discussed in this issue #289 .
I want to make the following:
- Just support for Sever-Side Rendering. Don’t support the browser side. Render it as strings, not virtual DOM
- Make it as middleware
- Zero-dependencies
- Use
c.render
method - Support
props.children
Code example:
import { Hono } from 'hono'
import { jsx } from 'hono/jsx'
import { Header, Footer } from './component'
const app = new Hono()
const Layout = (props) => {
<html>
<body>{props.children}</body>
</html>
}
type Props = {
message: string
}
const Top = <Props>(props) => {
return (
<Layout>
<Header />
<h1>{ props.message }</h1>
<Footer />
</Layout>
)
}
app.get('/', (c) => {
const message = 'Hello Hono!'
return c.render(<Top message={message} />)
})
app.fire()
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Middleware - Redux
Redux middleware solves different problems than Express or Koa middleware, but in a conceptually similar way. It provides a third-party ...
Read more >Redux Middleware – What it is and How to Build it from Scratch
In this article, we will explore what middleware is in Redux, why it's used, and how you can create your own middleware from...
Read more >An Overview of Redux Middleware for React Applications
An Overview of Redux Middleware for React Applications · 1. An event occurs · 2. An action is dispatched · 3. Reducer creates...
Read more >Writing Custom Middleware - LearnHowToProgram.com
In this lesson, we'll add Redux to our application and write a custom middleware function. Installing Redux. First, we'll add Redux and React...
Read more >JSX Middleware - Hono
JSX Middleware enable rendering HTML with JSX syntax. It's just for Sever-Side-Rendering. No virtual DOM. This middleware is only for writing with ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
👌
I too think it’s great to be able to use JSX SSR and Hotwire to generate HTML strings and still improve the UX without the development costs!
I know the Flareact. It seems to be a good framework like Next.js for Cloudflare Workers. And now, there is Remix that works in Cloudflare Workers. If I build a large website, I’ll use one of these frameworks.
But, if I build a few small HTML pages, it’s cumbersome to use these React-based frameworks. In the case of Hono, I want a tiny function to make HTML. It should not be React and having Virtual Dom. But, JSX is easy to write. So, I want a middleware that outputs HTML strings with JSX syntax.
And… isn’t it pretty cool that we can use JSX in Hono:)