Hono
@sawaratsuki1004: Hono logo is here🫠🫠🫠✌️✌️
https://pbs.twimg.com/media/GLtiVmZbYAABMax.png
さわらつき
Hono - Ultrafast web framework for the Edges
Cloudflare Workers
yusukebe
2022-01-27 Hono 炎っていうイケてる名前のフレームワークを作っている
2022-06-08 Cloudflare Workersフレームワーク「Hono」の紹介 - ゆーすけべー日記
$ npm create hono@latest
c(Hono)
Middleware
Middleware - Hono
回傳Response的單元為「Handler」
「Middleware」會在Handler的之前與之後執行,處理Request與Response
Request->MA->MB->MC->Handler->MC->MB->MA->Response,如同洋蔥一般
2025-01-20 【Honoミドルウェア】多分この書き方を知ってたら救われる編
Factory
Factory Helper - Hono
建立Hono元件的函式
例如可用於建立一Middleware、Handler,或是再建立一個Hono
2024-10-22 Honoの来た道とこれから - Speaker Deck
Trie構造的router
ElysiaJS
server-side JSX
middleware、handler:是否回傳Response object
v2
支援Deno、Bun
RPC
2024-12-21 エディタに優しいHonoのコードを考える
2023-12-11 HonoのNode.jsランタイムにマージされた神PRを見てみる - やわらかテック
2024-12-02 Honoの来た道とこれから 文字版!
範例
honojs/examples: Examples using Hono.
2024-12-02 Hono のサンプルコードの内側を覗く
2024-06-20 Honoを使い倒したい2024
2024-12-02 Honoマイベストプラクティス
SPA
yusukebe/hono-jsx-spa at minimal
最小規模的SPA
SSG
code:javascript
import { Hono } from 'hono'
import { toSSG } from 'hono/ssg'
import fs from 'fs/promises'
const app = new Hono()
app.get('/welcome', (c) => {
return c.render(
<html>
<body>
<h1>Hello world!</h1>
</body>
</html>
)
})
toSSG(app, fs)
SSG Helper - Hono
RPC
yusukebe/js-rpc-examples
Hono の RPC Client の仕組み
API
2022-08-29 Hono + Cloudflare Workers で REST API を作ってみよう
2025-01-11 Cloudflare Workers と Hono で軽量な Web API を作る|まくろぐ
2023-12-23 Hono でお問い合わせ API を作ろう!
重新導向
2024-05-03 Cloudflare WorkersとHonoでリダイレクトサービスを作る
code:javascript
app.get('/', (c) => {
return c.html(<h1>redirect to me</h1>);
});
app.get('*', (c) => {
const url = new URL(c.req.url);
const redirectUrl = url.pathname.substring(1) + url.search;
return c.redirect(redirectUrl, 302);
});
資訊安全
2024-12-11 Honoで実践するSPAセキュリティ強化の基本 #JWT - Qiita
防止bot:Cloudflare Turnstile
認證:JWT
CSRF、XSS攻擊
Remix
rphlmr/remix-hono-vite: Remix + Vite + Hono
emrancu/hono-remix-cloudflare-boilerplate: A ready-to-use template for building scalable serverless applications on Cloudflare Workers with Hono and Remix.
TanStack
bskimball/tanstack-hono: A simple example of using Tanstack Router SSR with Hono in a monolith
Next.js
2024-12-20 Cloudflare WorkersにNext.jsをデプロイしてみる
2024-12-17 Honoの捉え方、またはNext.jsとの組み合わせ方 | stin's Blog
React
https://github.com/yusukebe/hono-spa-react
2024-02-28 HonoでAPIだけ作って素のReact DOMでSPAを書くアーキテクチャ
2024-02-28 HonoでAPI付き雑React SPA最小
2025-09-19 Reactをクライアントで使わない - Speaker Deck
在伺服器端使用React
1. 讓Hono解釋JSX
更改副檔名為.tsx
編輯tsconfig.json
code:tsconfig.json(diff)
"compilerOptions": {
// ...
"jsx": "react-jsx",
- "jsxImportSource": "hono/jsx"
+ "jsxImportSource": "react"
},
2. 撰寫JSX
src/index.tsx
code:index.tsx
// ...
app.get('/', (c) => {
const Content = <h1>Hello</h1>
})
3. 算繪
src/index.tsx
code:index.tsx
// ...
import { renderToString } from 'react-dom/server'
app.get('/', (c) => {
const Content = <h1>Hello</h1>
return c.html(renderToString(Content))
})
renderToString
renderToStaticMarkup
renderToReadableStream
React的便利功能
Document Metadata
Resource Loading
Streaming + Suspense
React的生態系
在Hono上使用React
React Renderer Middleware
@hono/react-renderer
code:index.tsx
// ...
import { reactRenderer } from '@hono/react-renderer'
app.get(
'*',
reactRenderer(({ children }) => {
return (
<html>
<body>
<h1>React + Hono</h1>
<div>{children}</div>
</body>
</html>
)
})
)
app.get('/', (c) => {
return c.renderer(<p>Welcome!</p>)
})
vite-ssr-components
vite.config.ts
src/renderer.tsx
OAuth
2024-07-16 OAuthの仕組みを説明してHonoで実装してみる
登場人物
1. Resource owner
2. Resource server
3. Client
4. 授權server
流程
四種准許類型
准許授權code
准許隱式
准許client憑證
准許resource owner密碼憑證
准許授權code
取得授權code
1. 開始OAuth
2. 認證使用者
3. 同意委託權限
取得access token
取得resource
實作
2024-12-24 あらゆるフレームワークで Hono を使いたい
2024-12-17 HonoをCGIとして使ってみる