//h3-on-edgebypi0

h3-on-edge

⚡️ Edge workers with straming powered by unjs/h3

64
1
64
6
TypeScript

⚡️ H3 on the edge

This repo contains examples of unjs/h3 integration with popular runtime platforms.

H3 Web Adapter

With h3 (>= 1.8) you can easily integrate your app with any runtime platform supporting Fetch API (Request => Response).

import { createApp, eventHandler, toWebHandler } from "h3"; // or "https://esm.sh/h3@1.8.0"

const app = createApp();

app.use(
  "/",
  eventHandler((event) => "H3 works on edge!"),
);

// (Request) => Promise<Response>
const webHandler = toWebHandler(app);

You can virtually return anything from an event handler including web ReadableStream and Response!

See ./src/index.ts for main application and each platform details in next section.

Platforms

Cloudflare Workers

Deno

  • Deployment
  • Entry: ./src/deno.ts
  • Local dev: pnpm deno:dev
  • Local deploy: pnpm deno:deploy --token <deploy_token> --project <project_id>

Bun

Lagon

Netlify Edge

Setup Local Environment

  • Install latest version of Node.js (18 is recommended)
  • Enable Node.js corepack using corepack enable
  • Clone repository
  • Install dependencies using pnpm install
  • Start Node.js development server using pnpm dev

License

MIT - Pooya Parsa pooya@pi0.io

[beta]v0.13.0