github honojs/hono v3.9.0

latest releases: v4.4.2, v4.4.1, v4.4.0...
7 months ago

Release Notes

Hono v3.9.0 is out now! Let's take a look at what's new.

Improving the Developer Experience for JSX

Now we have the types for JSX.

Type definitions for JSX intrinsic elements are available. So, you can write your JSX with type annotation.

Screenshot 2023-10-27 at 16 03 54 Screenshot 2023-10-27 at 16 04 30

You can also override the definitions to add your custom elements and attributes.

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'my-custom-element': Hono.HTMLAttributes & {
        'x-event'?: 'click' | 'scroll'
      }
    }
  }
}

Clerk Middleware

Now Clerk Middleware is available! You can use Clerk for authentication in your application.

import { clerkMiddleware, getAuth } from '@hono/clerk-auth'
import { Hono } from 'hono'

const app = new Hono()

app.use('*', clerkMiddleware())
app.get('/', (c) => {
  const auth = getAuth(c)

  if (!auth?.userId) {
    return c.json({
      message: 'You are not logged in.'
    })
  }

  return c.json({
    message: 'You are logged in!',
    userId: auth.userId
  })
})

export default app

Thanks @octoper!

New Starter Template for Cloudflare Pages

The Cloudflare Pages starter template is now Vite-based! You can develop truly full-stack applications quickly and fast thanks to Vite's HMR.

SC

It uses Hono's original dev-server provided by @hono/vite-dev-server. And uses @hono/vite-cloudflare-pages for building the application. The config file is very neat.

import { defineConfig } from 'vite'
import devServer from '@hono/vite-dev-server'
import pages from '@hono/vite-cloudflare-pages'

export default defineConfig({
  plugins: [
    pages(),
    devServer({
      entry: 'src/index.tsx'
    })
  ]
})

You can use it with the create hono command:

npm create hono@latest

Ecosystem

The ecosystem has evolved. We introduce two products for Hono and one framework using Hono. Try them!

All Updates

Don't miss a new hono release

NewReleases is sending notifications on new releases.