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 - Ultrafast web framework for Cloudflare W...
Search
Yusuke Wada
November 26, 2022
Programming
3
8.3k
Hono - Ultrafast web framework for Cloudflare Workers, Deno, Bun, and Node.js
Yusuke Wada 2022.11.26 JSConf JP
Yusuke Wada
November 26, 2022
Tweet
Share
More Decks by Yusuke Wada
See All by Yusuke Wada
私はどうやって技術力を上げたのか
yusukebe
43
18k
Reactをクライアントで使わない
yusukebe
7
6.4k
AI時代のUIはどこへ行く?
yusukebe
22
10k
速いWebフレームワークを作る
yusukebe
5
1.8k
Honoアップデート 2025年夏
yusukebe
1
980
パスタの技術
yusukebe
1
650
AI Ramen Fight
yusukebe
0
180
TypeScriptでDXを上げろ! Hono編
yusukebe
4
1.1k
Honoをフロントエンドで使う 3つのやり方
yusukebe
8
5k
Other Decks in Programming
See All in Programming
CSC305 Lecture 05
javiergs
PRO
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
190
クラシルを支える技術と組織
rakutek
0
190
あなたの知らない「動画広告」の世界 - iOSDC Japan 2025
ukitaka
0
430
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
640
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
760
10年もののAPIサーバーにおけるCI/CDの改善の奮闘
mbook
0
790
Signals & Resource API in Angular: 3 Effective Rules for Your Architecture @BASTA 2025 in Mainz
manfredsteyer
PRO
0
110
育てるアーキテクチャ:戦い抜くPythonマイクロサービスの設計と進化戦略
fujidomoe
1
160
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
0
400
技術的負債の正体を知って向き合う / Facing Technical Debt
irof
0
120
CSC305 Lecture 06
javiergs
PRO
0
210
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
697
190k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
Six Lessons from altMBA
skipperchong
28
4k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
Thoughts on Productivity
jonyablonski
70
4.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Facilitating Awesome Meetings
lara
56
6.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
51k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
32
2.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Transcript
Yusuke Wada 2022.11.26 JSConf JP Hono Ultrafast web framework for
Cloud fl are Workers, Deno, Bun, and Node.js
Me • Yusuke Wada • Supervisor at TravelBook Inc. •
Web developer, Web framework developer • https://yusukebe.com/ • https://github.com/yusukebe 2
Today's topics • Core concepts of Hono 1. Multi-runtimes 2.
Ultrafast 3. Middleware 4. Experience 3
Hono in 1min. 4
Initial Commit • 2021-12-15 5
Star History 6
Who is using Hono • cdnjs API Server • Drivly
- Commerce infrastructure for the automotive industry • Ultra - Zero-Legacy Deno/React Suspense SSR Framework • Deno cli/bench/http 7
Workers Launchpad 8 ref: https://blog.cloud fl are.com/launchpad-fall-22/
Deno benchmarks 9 https://deno.land/benchmarks
Concept 1 Multi-runtimes 10
Hono works on... • Cloud fl are Workers / workerd
• Vercel Edge Runtime • Fastly Compute@Edge • Deno • Bun • Node.js • and more... 11
The same code runs on all platforms 12
Cloudflare Workers and Bun
Fastly Compute@Edge and Vercel Edge Runtime
Deno
Node.js
Thanks to Web standards • Zero-dependencies / No poly fi
ll • Web-interoperable Runtimes will be powered by WinterCG 17
Cloudflare Workers 18 ref: https://developers.cloud fl are.com/workers/runtime-apis/
Deno 19 ref: https://deno.land/
[email protected]
/runtime/web_platform_apis
Bun 20 ref: https://github.com/oven-sh/bun#Reference
Node.js 21 ref: https://github.com/honojs/node-server • Using `@remix-run/web-fetch`
context.ts 22 Discussion in WinterCG => https://github.com/wintercg/runtime-keys/pull/2
Great 👍 23
Concept 2 Ultrafast 24
Cloudflare Workers 25 ref: https://github.com/honojs/hono/tree/main/benchmarks/handle-event
Deno 26 ref: https://github.com/denosaurs/bench
Bun 27 ref: https://github.com/SaltyAom/bun-http-framework-benchmark
Node.js • Fastify • Reqs/sec 63417.00 5358.22 67487.06 • Express
• Reqs/sec 20709.94 1683.03 23045.34 • Hono with @honojs/node-server • Reqs/sec 32054.95 2642.04 35583.36 28
Node.js - router 29 Decode URI, Handle Query strings Does
not support regexp Does not support regexp
Why so fast? 30
3+1 Routers 1. StaticRouter • Fastest, supports only static routes.
2. RegExpRouter • Faster, supports almost routes. 3. TrieRouter • Slowest, supports all routes. But it's faster than other routers in the world. 31
"Linear" router 32
ref: https://github.com/yusukebe/pico
TrieRouter • Using Trie Tree structure • Support all patterns
34
None
RegExpRouter • Match the route with using one big Regex
made before dispatch. • By @usualoma • https://speakerdeck.com/usualoma/ultrafast-js-router 36
37
StaticRouter • Optimized for static routings • Does not support
dynamic routings such as "path parameters" 38
None
SmartRouter • The default router • Automatically picks the best
router from the three routers. 40 • StaticRouter • RegExpRouter • TrieRouter
Great 👍 41
Concept 3 Middleware 42
Small core • hono.ts • context.ts • compose.ts • request.ts
43 Basic app with Wrangler: Total Upload: 34.15 KiB / gzip: 8.26 KiB
Three types of Middleware • Built-in Middleware - including the
package • Custom Middleware - created by the users • Third-party Middleware - depends on external libraries 44
Built-in Middleware • Basic Auth • Bearer Auth • Cache
• Compress • CORS • Etag • html • JSX • JWT Auth • Logger • Pretty JSON • Serve Static • Validator 45
JSX Middleware 46
Validator Middleware 47
Custom Middleware 48
Third-party Middleware 49 • GraphQL Server • Firebase Auth •
Sentry • tRPC (?) ref: https://github.com/honojs/hono/issues/582
Great 👍 50
Concept 4 Experience 51
TypeScript • Wrangler, Deno, and Bun fi rst-class support TypeScript.
52
Path parameters 53
Validator Middleware 54
Easy to write tests • With `jest-environment-mini fl are` •
We can do test `Request` to `Response` 55
Great 👍 56
Example: Blog 57
import 58
Model 59
Logic 60
JSX 61
GET / 62
POST /post 63
Use cases in the real world 64
With Cloudflare R2 65 • github.com/yusukebe/r2-image-worker • Store and Deliver
images with R2 backend Cloud fl are Workers. ref: https://github.com/yusukebe/r2-image-worker
With Cloudflare D1 66 ref: https://blog.cloud fl are.com/making-static-sites-dynamic-with-cloud fl are-d1/
Cache control 67 ref: https://yusukebe.com/posts/2022/wsh/
Express alternative on Bun 68
Feature plans 69
Ecosystem • For Third-party Middleware • monorepo • API specs
as Types • tRPC like, but integrated 70
API specs as Types 71 ref: https://github.com/honojs/hono/issues/582
And... 72
Going to Standard web framework for Web standards 73
One more thing 74
Pico 75 Pico is ultra-tiny (about 1kB) web framework using
URLPattern. Pico works on Cloud fl are Workers and Deno. Pico is compatible with Hono.
Love 76
Thanks • Thanks to all contributors, all supporters, and all
users!! 77
Try Hono! 78 https://honojs.dev