Loading...
Loading...
Use @hono/inertia on the server and @ts-76/inertia-hono-jsx on the client to get SPA-style interactivity without leaving the Hono/hono-jsx stack.
npx skill4agent add yusukebe/skills hono-inertiahono/jsxhono/jsxhono@hono/inertiainertia({ rootView })c.render(name, props)@ts-76/inertia-hono-jsxcreateInertiaApp<Link><Form><Head>useFormuseHttp@inertiajs/corehono/jsx/dom@cloudflare/vite-pluginvite-ssr-componentscloudflare-workers+vite@hono/inertia/vitepages.gen.tsPagePropsFor<Name>c.render(Name, ...)yusukebe/hono-inertia-exampleapp/client.tsxapp/root-view.tsx@ts-76/inertia-hono-jsxhono/jsxapp/server.tswrangler.jsonc@hono/zod-validator// app/server.ts
import { Hono } from 'hono'
import { inertia } from '@hono/inertia'
import { rootView } from './root-view'
const app = new Hono()
app.use(inertia({ rootView }))
const routes = app
.get('/', (c) => c.render('Home', { message: 'Hono x Inertia' }))
.get('/users', (c) => c.render('Users/Index', { users: listUsers() }))
.get('/users/:id{[0-9]+}', (c) => {
const id = Number(c.req.param('id'))
const user = findUser(id)
if (!user) return c.notFound()
return c.render('Users/Show', { user })
})
export default routesc.render(name, props)@hono/inertiaX-Inertia// app/client.tsx
import { createInertiaApp } from '@ts-76/inertia-hono-jsx'
createInertiaApp({
resolve: (name) => {
const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
return pages[`./pages/${name}.tsx`]
},
})setup<App />hydrateRoothono/jsx/domdata-server-renderedcreateRoot// app/pages/Users/Index.tsx
import { Head, Link, type PageComponent } from '@ts-76/inertia-hono-jsx'
const UsersIndex: PageComponent<'Users/Index'> = ({ users }) => (
<main>
<Head title='Users' />
<h1>Users</h1>
{users.map((u) => (
<Link href={`/users/${u.id}`} key={u.id}>
{u.name}
</Link>
))}
</main>
)
export default UsersIndexPageComponent<'Users/Index'>pages.gen.ts@hono/inertia/vitejsxImportSource: "hono/jsx"tsconfig.jsonvite-ssr-components/hono/reactroot-view.tsx@cloudflare/vite-pluginwrangler deploy@ts-76/inertia-hono-jsxhono/jsxhono/jsx/domX-Inertia-Version@cloudflare/vite-plugin