Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hono v3 - Do Everything, Run Anywhere, But Small, And Faster

Hono v3 - Do Everything, Run Anywhere, But Small, And Faster

About the next major version of Hono. "v3".

Yusuke Wada

January 24, 2023
Tweet

More Decks by Yusuke Wada

Other Decks in Programming

Transcript

  1. Yusuke Wada 2023-01-24 Serverless Frontend Meetup Hono v3 Do Everything,

    Run Anywhere, But Small, And Faster * will be released soon!
  2. Me • Yusuke Wada • Supervisor at TravelBook Inc. •

    Web developer, Web framework developer • https://yusukebe.com/ • https://github.com/yusukebe 2
  3. Ultrafast web framework for Cloudflare Workers, Deno, Bun, and Node.js

    3 What's Hono?
  4. Without Hono

  5. With Hono

  6. 6 Web frameworks/routers for Cloudflare Workers •itty-router ~550 bytes •Sunder

    •Worktop •Hono
  7. •Fast - 3+1 Routers •Tiny - about 20kB •Multi-runtimes -

    CF, Fastly, Deno, Bun, Lagon, Node.js •Fine DX - TypeScript •Batteries Included - Middleware 7 Hono Features
  8. •Deno •Deno Benchmark •cdnjs •Ultra - Deno/React SSR Framework •Cloud

    fl are D1 example •substats •Kings League Project •react-starter-kit •Driv.ly 8 Who uses Hono?
  9. Demo 1-minute deploy 9

  10. Current version v2.7.5 shipped today 10

  11. Going to "v3" Not released yet but will be soon.

    11 Do Everything, Run Anywhere, But Small, And Faster
  12. Run anywhere 12

  13. 13 Multi-runtimes CI support

  14. Node.js support 14

  15. Adapters 15 Cloud fl are Workers, Cloud fl are Pages,

    Bun, Deno are available
  16. Cloudflare Pages

  17. `/functions` 17

  18. Next.js Edge API Routes

  19. Use middleware on Vercel 19

  20. Anywhere! thanks to Web Standard • Cloud fl are Workers

    • Cloud fl are Pages • Fastly [email protected] • Deno • Bun • Lagon • Vercel • Node.js • ... 20 Hono may work on every JavaScript runtime!
  21. Faster 21

  22. Performance improvement 22 15% faster! 3% slower:( Using https://github.com/SaltyAom/bun-http-framework-benchmark Measured

    on 2023-01-22
  23. Small 23

  24. A little fatter, but still small. 24 Express => 572

    kB Fastify => 1.2 MB [email protected] => 48 kB
  25. Pico - Ultratiny web framework 25 https://github.com/yusukebe/pico May be placed

    on @hono/pico ??
  26. Do everything 26

  27. RPC mode - like tRPC but integrated, too simple 27

  28. 1. Server: Write the schema 28

  29. 2. Use `zod-validator` Middleware 29

  30. 3. Write the endpoint with `jsonT()` and `build()` 30

  31. 4. Export "types" 31

  32. 5. Client: Use `@honoj/hc` and import "types" 32

  33. 6. Post JSON and parse the response 33

  34. Share the API specs 34

  35. Demo: https://github.com/honojs/hono/issues/727#issuecomment-1369078973 35

  36. Great 👍 36

  37. `create hono` command 37

  38. @honojs to `@hono` ! 38 • We can make packages

    such middleware as `@hono/xxx` • Middleware • @hono/zod-validator • @hono/qwik-city • @hono/graphql-server - by @metrue • @hono/sentry by @sam-lippert • @hono/ fi rebase-auth by @Code-Hex • @hono/node-server • @hono/hc
  39. Ecosystem 39 Hono Middleware hc node-server Adapter Pico `create hono`

  40. @hono/qwik-city 40 Works on Cloud fl are Workers and Bun

    (also on Deno?)
  41. It works on your runtime if it works on Hono

    41
  42. Others • `HonoRequest` • `HTTPException` • Router - regexp with

    slash support 42
  43. Hono v3 will be released soon! 43