-
Notifications
You must be signed in to change notification settings - Fork 39
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: Script
and HasIsland
available at multiple runtimes with AsyncLocalStorage
#168
feat: Script
and HasIsland
available at multiple runtimes with AsyncLocalStorage
#168
Conversation
Yes, we have to set it. But there is a difference between Cloudflare Workers and Cloudflare Pages. We intent HonoX works on Pages, I'll check whether that setting works or not in Pages. |
Hmm. It works well in local development. For production. When we use Cloudflare Workers, we write |
For this matter, I was thinking of providing the components by each adapter separate from import { Script } from 'honox/react/server' Or creating import { Script } from '@honox/react/server' With this method, we can introduce the method for // app/client.ts
import { createClient } from 'honox/react/client'
// Or, import { createClient } from '@honox/react/client'
createClient() Anyway, it would be best if we didn't have to make the adapter per UI library. |
e90fa80
to
4e41724
Compare
Hi @usualoma Sorry!! I was mistaken. I asked a Cloudflare Pages team, and I tried it, and now Sorry for taking the trouble for you by having #170 made. Why don't we go with this approach? |
Great!!
#170 is part of a number of things we've tried, so don't worry about it. If we merge this PR.There is one point of concern. If we merge this, I tried "importing AsyncLocalStorage dynamically and not raising an error if import fails", but it didn't work, and even if it did work, I don't think it would be good from a DX perspective. Benefits of being able to use AsyncLocalStorageThis would provide a "renderer-independent useRequestContext". Even if (and I don't know if this is actually the case) the user is using their own Thus, if we decide to make honox itself (not only HasIsland) dependent on |
I think it's not a blocker. We need just update the starter template and write about the
Yeah. I was thinking
Let's go with |
@yusukebe |
d23bde1
to
4d52781
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -62,6 +63,11 @@ export const createApp = <E extends Env>(options: BaseServerOptions<E>): Hono<E> | |||
const app = options.app ?? new Hono() | |||
const trailingSlash = options.trailingSlash ?? false | |||
|
|||
// Share context by AsyncLocalStorage | |||
app.use(async function ShareContext(c, next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool! Only a few code can adapt AsyncLocalStorage
to a Hono app.
Hi @usualoma Thanks! Let's go with this. |
#167
This appears to be a good and simple solution to implement.
However (I am not familiar with Cloudflare Workers, so maybe there is another solution) it appears that
compatibility_flags = [ "nodejs_compat"]
needs to be added to wrangler.toml.