Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic implementation #1

Merged
merged 5 commits into from
Dec 26, 2023
Merged

feat: basic implementation #1

merged 5 commits into from
Dec 26, 2023

Conversation

yusukebe
Copy link
Member

This is an initial PR for HonoX!

HonoX is a new meta-framework that enables a files-based routing and supports the client side with island hydration. It is formerly Sonik.

The diffences with Sonik

The main difference with Sonik is that it is Renderer-based. We can define UI things with renderer in _renderer.tsx instead of _layout.tsx. Using the Renderer, you can flexibly specify layouts without being tied to a UI library. You can also use the assets of Hono's renderer middleware.

// app/routes/_renderer.tsx
import { jsxRenderer } from 'hono/jsx-renderer'

export default jsxRenderer(({ children, title }) => {
  return (
    <html lang='en'>
      <head>
        <meta charset='UTF-8' />
        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
        {title ? <title>{title}</title> : ''}
      </head>
      <body>{children}</body>
    </html>
  )
})

Also, each route is now defined as a (Handler | MiddlewareHandler)[]. This allows you to use middleware such as Zod Validator with the type enabled.

import { z } from 'zod'
import { zValidator } from '@hono/zod-validator'

const schema = z.object({
  name: z.string().max(10),
})

export const POST = createRoute(zValidator('form', schema), async (c) => {
  const { name } = c.req.valid('form')
  setCookie(c, 'name', name)
  return c.redirect('/')
})

Including v4 release

I would like to make HonoX the highlight feature of the next major Hono release v4. Until then, we will keep this repository https://github.com/honojs/honox private and improve it.

What to do in this PR

I would like to discuss the basic API before merging it into the main. I think this is the best we can do, but I want to hear any feedback if you have any.

@yusukebe
Copy link
Member Author

yusukebe commented Dec 23, 2023

Hey @usualoma !

Let's go to the next stage! I want to know your thoughts about HonoX!

@yusukebe yusukebe merged commit 387e809 into main Dec 26, 2023
1 check passed
@yusukebe yusukebe deleted the initial branch December 26, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant