-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
'use client'
or islands
dir
#2002
Comments
@usualoma I want to know your opinion. |
Hi, @yusukebe I was not familiar with islands architecture, so I copied what I knew about Next.js, but I don't have any particular desire to stick to my own way of doing things.
I don't think this point is Pros only for the Well, I think the If we later decide that we want to use the |
I like the simplicity of the islands implementation, but one potential big drawback is the inability to use component libraries that make use of You'd have to wrap each component in an island component to make it work, which is kind of comical because everyone had to wrap components with I'd put my vote with |
@usualoma commented:
Indeed. That's true. I'll edit the above. |
I have a idea. import { Island } from 'hono/jsx'
import Counter from './Counter'
app.get('/', c => c.html(<main>
<Island island={Counter} props={{}} />
</main>)) How about you my idea?
|
This might be a tiny bit cleaner import { Island } from 'hono/jsx'
import Counter from './Counter'
app.get('/', c => c.html(
<main>
<Island>
<Counter props={{}} />
</Island>
</main>
)) Although going with |
Thanks all! We are going with the "islands dir": https://github.com/honojs/honox?tab=readme-ov-file#interactions |
Thanks to @usualoma, JSX "Client Components" are working for real. Next, we need to figure out how to integrate it into the framework. Specifically, how to hydrate the Client Components in the HTML rendered by the server.
Here, we discuss "Which component becomes a Client Component?" There are two ways. Using the
'use client'
directive and using theislands
directory.'use client'
The
'use client'
directive is an API in React, used in Next.js. Although it may not be the original usage of React, we can consider a component with'use client'
at the beginning to be a client component.This is @usualoma implementing PoC. There are things we need to improve, but the approach to make it a Vite plugin would be good.
https://github.com/usualoma/hono-dom-hcc
islands
directory patternThe
islands
directory pattern is an approach that puts the components you want to be client components in a specific directory, such as/app/islands
. Fresh uses it.Sonik also uses this approach. The Vite plugin loads the components in
/app/islands
and marks them as client components.'use client'
vsislands
dirThe following are just a few things I can think of. If there are others, please let me know.
'use client'
:islands
directory pattern:Pros: Can use other UI libraries such as React and Preact. Sonik do it.use client
could also use other UI libraries.Make it a Vite plugin
If we decide to go either way, it would be implemented as a Vite plugin.
This is just a matter of which component we consider the client component. But we have to decide.
The text was updated successfully, but these errors were encountered: