Hono provides a comprehensive JSX implementation that works seamlessly for both server-side and client-side rendering. Unlike traditional JSX libraries, Hono’s JSX is designed to be lightweight, fast, and works directly with Hono’s request/response model.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/honojs/hono/llms.txt
Use this file to discover all available pages before exploring further.
What is Hono JSX?
Hono JSX is a React-like JSX implementation that:- Works on the server - Renders directly to HTML strings
- Works on the client - Provides DOM rendering capabilities
- React-compatible - Uses familiar React APIs and hooks
- Type-safe - Full TypeScript support with proper type inference
- No build required - Works with standard JSX transpilation
Hono JSX is compatible with React 19 APIs and provides hooks like
useState, useEffect, useContext, and more.TypeScript Configuration
To use JSX in your Hono project, configure yourtsconfig.json:
For Server-Side Rendering
tsconfig.json
For Client-Side Rendering
tsconfig.json
Basic Usage
Here’s a simple example using JSX in a Hono application:JSX Components
Hono JSX supports functional components with props:Props and Children
Components receive props and children just like React:hono/jsx vs hono/jsx/dom
Hono provides two JSX implementations:hono/jsx
Server-side rendering
- Renders to HTML strings
- Used in route handlers with
c.html() - Optimized for server performance
- Supports async components
hono/jsx/dom
Client-side rendering
- Renders to actual DOM
- Used for interactive UIs
- React-compatible hooks
- Supports hydration
Attributes and HTML Properties
Hono JSX supports standard HTML attributes:Style Objects
Styles can be passed as objects:Fragments
Use fragments to return multiple elements:Conditional Rendering
Render elements conditionally:Lists and Keys
Render lists with keys:dangerouslySetInnerHTML
Insert raw HTML (use with caution):API Compatibility
Hono JSX exports aversion that indicates React API compatibility:
Next Steps
Server Rendering
Learn about server-side JSX rendering with Hono
DOM Rendering
Build interactive UIs with client-side rendering
Streaming
Stream HTML with Suspense-like patterns
Helpers
Use the HTML helper for advanced rendering