Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hono v3 and v4
Search
Yusuke Wada
November 19, 2023
Programming
4
3.9k
Hono v3 and v4
JSConf JP
Nov 19, 2023. Yusuke Wada
Yusuke Wada
November 19, 2023
Tweet
Share
More Decks by Yusuke Wada
See All by Yusuke Wada
MCP with Cloudflare Workers
yusukebe
2
220
Remix on Hono on Cloudflare Workers
yusukebe
3
420
僕がつくった48個のWebサービス達
yusukebe
20
17k
Honoの来た道とこれから
yusukebe
20
4.7k
JS RPCを理解する
yusukebe
5
720
Honoとhtmx
yusukebe
6
1.8k
Cloudflare Workersの環境を再現することについて
yusukebe
7
1k
Hono v4
yusukebe
11
5k
The power of Web-standards
yusukebe
4
1.7k
Other Decks in Programming
See All in Programming
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
命名をリントする
chiroruxx
1
390
Symfony Mapper Component
soyuka
2
730
良いユニットテストを書こう
mototakatsu
5
1.9k
Full stack testing :: basic to basic
up1
1
930
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
Criando Commits Incríveis no Git
marcelgsantos
2
170
Go の GC の不得意な部分を克服したい
taiyow
2
760
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
3
1k
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Optimising Largest Contentful Paint
csswizardry
33
3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Rails Girls Zürich Keynote
gr2m
94
13k
The Language of Interfaces
destraynor
154
24k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
96
Making Projects Easy
brettharned
116
5.9k
Transcript
Hono v3 and v4 JSConf JP Nov 19, 2023. Yusuke
Wada
ࣗݾհ • Yusuke Wada • Web framework developer • Developer
Advocate @Cloud fl are • Bokete co-founder • Creator of Hono • https://github.com/yusukebe
ࠓͷτϐοΫ 1. Hono v3.*ͷػೳ 2. Hono v4ͰͲ͏ͳΔͷ͔ʁ
Honoͱʁ • Web-framework runs on any JavaScript runtime. • Fast,
Lightweight, Web-standards. • Works on… • Cloud fl are Workers • Deno • Bun • Node.js • Fastly Compute • AWS Lambda • Vercel • Others! https://hono.dev
GitHub Stars ⭐
Who is using Hono? • cdnjs API Server • Poly
fi ll.io • Deno Docs • Ultra • Cloud fl are Blog • Workers SDK • Cloud fl are D1 • Drivly • SticAI • Skill Struck • Reejs • toddle • LanderLab • OpenStatus • Loglib • repeat.dev • Nodecraft • Hwy • Unkey • AI.LS • ExpenSee • Others!
v2·ͰͷҰൠతͳػೳ • ϧʔςΟϯά • Request/ResponseΛѻ͏ • Text/JSON/HTMLϨεϙϯεΛฦ͢ • ϛυϧΣΞΛ͏ •
BindingsɺมΛѻ͏ • Cloud fl are WorkersɺDenoɺBunͰಈ͔͢
v3.*ͰೖͬͨػೳΛհ͠·͢ • v3.0.0 => 2023/02/18ʹϦϦʔε • v.3.10.0 => 2023/11/13ʹϦϦʔε •
جຊతʹsemverΛक͍ͬͯΔͷͰminorϦϦʔεΛհ • ͋ͳ͕ͨΒͳ͍͔͠Εͳ͍Hono
v3.0.0 - 2023/02/18 • HonoRequest • RegExpRouter becomes the fastest
router • Good-bye StaticRouter • New Validator • RPC • Adapter • Muti-runtime CI Support • Support WinterCG Runtime Keys • create-hono • @honojs to @hono
RegExpRouter becomes the fastest router 20232݄࣌ͷϕϯνϚʔΫͰ͢ • RegExpRouter͕ JavaScriptքͰ1൪ ͍ϧʔλʔͷͻͱ
ͭʹͳͬͨ
New Validator • ബ͘ͳͬͨ • ZodɺValibotɺTypeBox ͳͲ֎෦ͷValidatorΛ ༻͢Δ3rd-partyϥΠϒ ϥϦ •
ܕ͚
RPC-mode • ΫϥΠϯτΛੜ͢Δ`hc()`Λಋೖ • αʔόʔଆͷܕΛड͚͠ɺAPIεϖοΫΛڞ༗͢Δ • tRPCͷΑ͏͕ͩɺ͍ͭͷΞϓϦΛ؆୯ʹҠߦͰ͖Δ • ྫ͑Zod/Zod Validator/hcͷελοΫͰͰ͖Δ
None
Multi-runtime CI Support 202311݄ݱࡏɺMainͷଞʹ7ͭͷϥΠϯλΠϜͷςετ͕Δ
v3.1.0 - 2023/03/17 • Improve RPC-mode • `env` for getting
environment variables for multi-runtimes • AWS Lambda Adapter • basePath() • c.req.path • Allow passing RequestInit to c.json() etc.
`env` for getting environment variables for multi-runtimes • ϥϯλΠϜʹґଘͤͣಁաతʹڥมΛऔಘ͢ΔͨΊͷ`env()`
AWS Lambda Adapter • AWS LambdaʹରԠ
v3.2.0 - 2023/05/19 • New Routers • Presets: `hono/tiny`, `hono/quick`
• app.mount() • Node.js adapter server v1.0.0 has been released • Support for routing includes a hostname
New Routers • LinearRouter • ϧʔςΟϯάͷొ͕͍ϧʔλʔ • PatternRouter • ͱʹ͔͘খ͍͞ϧʔλʔ
ܭ5ͭͷϧʔλʔʹͳͬͨ TrieRouter RegExpRouter SmartRouter LinearRouter PatternRouter
Presets: `hono/tiny`, `hono/quick` • `hono/tiny` • PatternRouterͷΈ • খ͍͞ •
13KB • `hono/quick` • LinearRouterͱTrieRouter • ϧʔτͷొ͕͍
ͲͷPresetΛ͏͖͔ hono ͍ DenoɺBunɺNode.js Cloud fl are Workers hono/quick ొ͕͍
Fastly Compute hono/tiny খ͍͞ Ϧιʔε͕ݶΒΕ͍ͯΔڥ
app.mount() • ͲΜͳ`fetch` ΞϓϦέʔγϣϯͰmountͰ͖Δ
itty-router, Remix, Qwik City, Solid StartͳͲ͍͚Δ
֤ϑϨʔϜϫʔΫ͕ΞμϓλΛ࡞͍ͬͯͨ
HonoʹϚϯτͤ͞ΕͲΜͳϓϥοτϑΥʔϜͰಈ͘
Node.js adapter server v1.0.0 • Poly fi llͳ͠ɺNode.jsωΠςΟϒͳWeb-standards APIͷΈΛ༻
v3.3.0 - 2023/07/11 • Server-Timing Middleware • Lambda@Edge Adapter
Server-Timing Middleware • Server-Timing APIΛͬͯύ ϑΥʔϚϯεܭଌ͕Ͱ͖Δ
v3.4.0 - 2023/08/08 • Netlify Adapter • Cookie Middleware supports
Signed Cookies
v3.5.0 - 2023/08/21 • Secure Headers Middleware • Introduce “Helpers”
• Zod OpenAPI Hono
Secure Headers Middleware • ηΩϡϦςΟʹ·ͭΘΔϔο μͷઃఆ͕Ͱ͖Δ • ExpressͷHelmet૬
Introduce “Helpers” • ϛυϧΣΞͱҧ͍ศརϝιουΛఏڙ͢Δ
ࠓ͋ΔHelpers • Adapter • Cookie • Factory • html •
JWT • Streaming • Testing
Zod OpenAPI Hono • ͷOpenAPIαϙʔτ • HonoΛϥοϓͨ͠Ϋϥε • Zodͱ”Zod to
OpenAPI”Λ͍ͬͯΔ
1. ZodͰεΩʔϚΛॻ͘
2. ϧʔτΛ࡞Δ
3. ΞϓϦʹ͢Δ
4. JSONͷυΩϡϝϯτ͕ు͚Δ
None
5. Swagger UI MiddlewareͱΈ߹ΘͤΔ
None
ܕ͕ͭ͘
v3.6.0 - 2023/09/11 • Introduce `c.render()` • Introduce `c.var` •
`FC` for JSX • `$url()` in Hono Client • Vite dev-server for Hono • Deprecate some properties in HonoRequest • Replaced Jest with Vitest
Introduce `c.render()` • HTMLͷϨΠΞτΛ؆୯ʹͭͬͯ͘దԠ͘͢͠ Middleware Handler Result
Vite dev-server for Hono • `@hono/vite-dev-server` • Viteͷಠࣗdev serverΛఏڙ͢ΔVite plugin
• Viteܦ༝Ͱ`fetch`ΞϓϦΛ։ൃͰ͖Δ • ࠶ىಈɺϦϩʔυ͕͍ • ϑϩϯτରԠ • Cloud fl areͷBindingsαϙʔτ͍ͯ͠Δ
None
v3.7.0 - 2023/09/21 • `c.stream()` and `c.streamText()` • Testing Helper
• JWT helper
`c.stream()` and `c.streamText()` • ͷStreamରԠ • Zod OpenAPIͱ߹ΘͤͯAI readyʹ
None
v3.8.0 - 2023/10/19 • JSX Context API • JSX Renderer
Middleware • Streaming Helper • Factory Helper • `parseBody()` supports multi values • Improve path matching in the router
JSX Renderer Middleware • `c.render()`Ͱ͏ͨΊͷϨΠΞτΛ JSXͰఆٛ͘͢͠ • `useRequestContext()`ͰContextΦ ϒδΣΫτ͕औΕΔΑ͏ʹͳΔ
Streaming Helper • `streamSSE()`ͰServer-Sent Events͕ు͚Δ
Factory Helper • `createMiddleware()`͕ຯʹศར • ܕղܾΛͬͯ͘Δ
v3.9.0 - 2023/10/27 • Improving the Developer Experience for JSX
• Clerk Middleware • New Starter Template for Cloud fl are Pages
Improving the Developer Experience for JSX • λάʹܕ͕͍ͭͨɻΤσΟλͰิॿͯ͘͠ΕΔ
New Starter Template for Cloudflare Pages • `@hono/vite-dev-server`Λར༻ͨ͠৽͍͠ελʔλʔ
v3.10.0 - 2023/11/13 • JSX supports Async Components • Introduce
`Suspense` and `renderToReadableStream()` • JSX Renderer Middleware supports `stream` • Support `@jsx precompile` for Deno
JSX supports Async Components • JSXͷίϯϙʔωϯτͷதͰasync/awaitͰ͖Δ
Introduce `Suspense` and `renderToReadableStream()` • AsyncComponent`fetch`͕ऴΘΔ·Ͱawait͢Δ • SuspenseΛ`renderToReadableStream()`ͱ͏ͱ`fetch`͕ऴΘΔؒ fallbackΛදࣔɺղܾ͞ΕͨΒ݁ՌΛදࣔ
None
None
JSX Renderer Middleware supports `stream` • `stream: true`ʹ͢Δ͜ͱͰ StreamingͷϨεϙϯεʹͳΔ
v3.*Ͱಋೖ͞ΕͨػೳΛΈ͖ͯ·ͨ͠ • v3.0.0 => 2023/02/18 • v3.1.0 => 2023/03/17 •
v3.2.0 => 2023/05/19 • v3.3.0 => 2023/07/11 • v3.4.0 => 2023/08/08 • v3.5.0 => 2023/08/21 • v3.6.0 => 2023/09/11 • v3.7.0 => 2023/09/21 • v3.8.0 => 2023/10/19 • v3.9.0 => 2023/10/27 • v3.10.0 => 2023/11/13
ͬͯΈͯͩ͘ ͍͞
v4?
v4? When? What?
What is introduced in v4?
File-base Routing??
Thanks