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

Documentation/example of how to run h3 in a worker environment #39

Closed
JamieCurnow opened this issue Oct 13, 2021 · 6 comments
Closed

Documentation/example of how to run h3 in a worker environment #39

JamieCurnow opened this issue Oct 13, 2021 · 6 comments
Labels
documentation Improvements or additions to documentation pending

Comments

@JamieCurnow
Copy link

I'm trying to get started with h3 in a Cloudflare worker - are there any examples of how to get started with h3 in workers?

import { createApp } from 'h3'

const app = createApp()
app.use('/', () => 'Hello world')

addEventListener('fetch', (e) => {
  // ???
})
@pi0
Copy link
Member

pi0 commented Oct 13, 2021

Hi @JamieCurnow. It is not straightforward at the moment without using nuxt nitro but would definitely work on docs to explain usage without nuxt nitro.

In the meantime, here are overall steps hopefully can help you to implement:

@JamieCurnow
Copy link
Author

@pi0 Thank you for pointing me in the right direction! You're right - it's not straightforward at the moment 😅

I managed to figure it out though and made a little helper package that wraps around h3's createApp and exposes a function to handle the fetch event from Cloudflare.

In case anyone else is trying to do this too check out:
https://github.com/JamieCurnow/h3-worker#readme

Needs a good test, but is working for my use case. Suggestions/questions/pull requests are welcome as always :)

@jontybrook
Copy link

@JamieCurnow thanks for this, helped me out a lot!

@renhiyama
Copy link

@pi0 can we expect docs anytime soon on this?

@nozomuikuta nozomuikuta added the documentation Improvements or additions to documentation label Dec 12, 2022
@Hebilicious Hebilicious added the pending label Jul 4, 2023 — with Volta.net
Copy link
Member

Hebilicious commented Jul 4, 2023

Pending until we have full Response/Request support #401

@pi0
Copy link
Member

pi0 commented Jul 27, 2023

Workers support with h3 itself will be much more straight forward with upcoming fetch adapter. Please track via #458

@pi0 pi0 closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation pending
Projects
None yet
Development

No branches or pull requests

6 participants