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
270
僕がつくった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
990
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
みんなでプロポーザルを書いてみた
yuriko1211
0
260
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
Jakarta EE meets AI
ivargrimstad
0
580
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
5
1.7k
イベント駆動で成長して委員会
happymana
1
320
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
macOS でできる リアルタイム動画像処理
biacco42
9
2.3k
役立つログに取り組もう
irof
28
9.6k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1k
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
How STYLIGHT went responsive
nonsquared
95
5.2k
RailsConf 2023
tenderlove
29
900
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Optimizing for Happiness
mojombo
376
70k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
What's in a price? How to price your products and services
michaelherold
243
12k
Building Applications with DynamoDB
mza
90
6.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
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