$30 off During Our Annual Pro Sale. View Details »

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!

    View Slide

  2. Me
    • Yusuke Wada
    • Supervisor at TravelBook Inc.
    • Web developer, Web framework developer
    • https://yusukebe.com/
    • https://github.com/yusukebe
    2

    View Slide

  3. Ultrafast web framework for Cloudflare Workers,
    Deno, Bun, and Node.js
    3
    What's Hono?

    View Slide

  4. Without Hono

    View Slide

  5. With Hono

    View Slide

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

    View Slide

  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

    View Slide

  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?

    View Slide

  9. Demo
    1-minute deploy
    9

    View Slide

  10. Current version
    v2.7.5
    shipped today
    10

    View Slide

  11. Going to "v3"
    Not released yet but will be soon.
    11
    Do Everything, Run Anywhere,
    But Small, And Faster

    View Slide

  12. Run anywhere
    12

    View Slide

  13. 13
    Multi-runtimes CI support

    View Slide

  14. Node.js support
    14

    View Slide

  15. Adapters
    15
    Cloud
    fl
    are Workers, Cloud
    fl
    are Pages, Bun, Deno are available

    View Slide

  16. Cloudflare Pages

    View Slide

  17. `/functions`
    17

    View Slide

  18. Next.js Edge API Routes

    View Slide

  19. Use middleware on Vercel
    19

    View Slide

  20. Anywhere! thanks to Web Standard
    • Cloud
    fl
    are Workers
    • Cloud
    fl
    are Pages
    • Fastly Compute@Edge
    • Deno
    • Bun
    • Lagon
    • Vercel
    • Node.js
    • ...
    20
    Hono may work on every JavaScript runtime!

    View Slide

  21. Faster
    21

    View Slide

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

    View Slide

  23. Small
    23

    View Slide

  24. A little fatter, but still small.
    24
    Express => 572 kB
    Fastify => 1.2 MB
    [email protected] => 48 kB

    View Slide

  25. Pico - Ultratiny web framework
    25
    https://github.com/yusukebe/pico
    May be placed on @hono/pico ??

    View Slide

  26. Do everything
    26

    View Slide

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

    View Slide

  28. 1. Server: Write the schema
    28

    View Slide

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

    View Slide

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

    View Slide

  31. 4. Export "types"
    31

    View Slide

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

    View Slide

  33. 6. Post JSON and parse the response
    33

    View Slide

  34. Share the API specs
    34

    View Slide

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

    View Slide

  36. Great 👍
    36

    View Slide

  37. `create hono` command
    37

    View Slide

  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

    View Slide

  39. Ecosystem
    39
    Hono
    Middleware
    hc
    node-server
    Adapter
    Pico
    `create hono`

    View Slide

  40. @hono/qwik-city
    40
    Works on Cloud
    fl
    are Workers and Bun (also on Deno?)

    View Slide

  41. It works on your runtime if it works on Hono
    41

    View Slide

  42. Others
    • `HonoRequest`
    • `HTTPException`
    • Router - regexp with slash support
    42

    View Slide

  43. Hono v3 will be released soon!
    43

    View Slide