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.8k
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
Remix on Hono on Cloudflare Workers
yusukebe
1
280
僕がつくった48個のWebサービス達
yusukebe
20
17k
Honoの来た道とこれから
yusukebe
19
3.2k
JS RPCを理解する
yusukebe
5
680
Honoとhtmx
yusukebe
6
1.8k
Cloudflare Workersの環境を再現することについて
yusukebe
7
1k
Hono v4
yusukebe
11
4.8k
The power of Web-standards
yusukebe
4
1.7k
実践エッジユースケース
yusukebe
7
2.2k
Other Decks in Programming
See All in Programming
イベント駆動で成長して委員会
happymana
1
320
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
580
Outline View in SwiftUI
1024jp
1
320
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
CSC509 Lecture 09
javiergs
PRO
0
140
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.9k
Quine, Polyglot, 良いコード
qnighy
4
640
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
50
7.2k
Six Lessons from altMBA
skipperchong
27
3.5k
Visualization
eitanlees
145
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Designing Experiences People Love
moore
138
23k
A Tale of Four Properties
chriscoyier
156
23k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
A Modern Web Designer's Workflow
chriscoyier
693
190k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing for humans not robots
tammielis
250
25k
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