H
Hono3d ago
gavriguy

Using honox client.ts to load web components

I'm using honox client.ts to load web components I created in Lit. It works great but only when I have at least one island on the route. How can I make sure the js is loaded even when I don't have island on the route. I'm using <Script src='/app/client.ts' async /> in my _renderer.tsx file`
6 Replies
atoko
atoko3d ago
Check the honox docs, react renderer part, it describes the manual <script> tags to use (lowercase S)
gavriguy
gavriguyOP3d ago
thanks I'll give it a try
atoko
atoko3d ago
Oh, before the react part, you can just use the lowercase script tags
atoko
atoko3d ago
No description
atoko
atoko3d ago
Take out has islands and there you go
gavriguy
gavriguyOP3d ago
As I have a hashed version of the script file, I ended up copying https://github.com/honojs/honox/blob/main/src/server/components/script.tsx#L33 and removing the <HasIslands> check from the code. Thank you. it might be a good idea to allow to enable disable the <HasIslands> from the Script component props. I can make a PR if it makes sense
GitHub
honox/src/server/components/script.tsx at main · honojs/honox
HonoX - Hono based meta framework. Contribute to honojs/honox development by creating an account on GitHub.

Did you find this page helpful?