edge-mw
v0.1.0
Published
Edge-style middleware library (Next-like) for Vite apps — ready-to-run example repo.
Readme
edge-mw
Edge-style middleware library (Next-like) for Vite apps — ready-to-run example repo.
Features
createEdgeMiddlewareruntime wrapper for Edge handlersNextResponsehelpers (next,redirect,rewrite,json)- Mini cookie parser
- Vite dev proxy example for local middleware testing via Miniflare
- Cloudflare Worker example entrypoint
Quickstart (local)
- Install:
npm install - Build TypeScript:
npm run build - Start Miniflare (runs the worker):
npm run mf:dev - In another terminal start Vite (dev site):
npm run dev
The repository includes worker/worker.ts (Cloudflare Worker entry) that uses the middleware.
Publish
- Build:
npm run build - Bundle the worker (use esbuild or Wrangler) and deploy to Cloudflare Workers, Deno Deploy, or Vercel Edge.
Structure
src/— library sourceworker/— example Cloudflare Worker entrypointvite.config.ts— Vite config (example)
Notes
This scaffold is a starting point. See src/ for the middleware implementation and examples.
