What is export?
export lets you write normal functions and classes on a Cloudflare Worker, then import them from any client -- browser, Node.js, Deno, or another Worker -- using just the Worker URL.
javascript
// On the server: write functions as usual
export function greet(name) {
return `Hello, ${name}!`;
}
// On the client: import from the Worker URL
import { greet } from "https://my-worker.workers.dev/";
await greet("World"); // "Hello, World!"No SDK. No code generation. No client-side build step.
Two Ways to Use
New Project
bash
npm create export my-app
cd my-app && npm install
npm run devExisting Vite Project
bash
npx exportc init
cd export && npm install && cd ..
npm run devThe Vite plugin auto-starts Wrangler, auto-generates TypeScript types, and deploys to Workers Sites with npm run export.
How it works
- Your Worker exports functions and classes in
src/index.ts - When a client imports the Worker URL, a tiny ESM glue module is returned
- That module opens a WebSocket and creates Proxy objects for each export
- Function calls are serialized with devalue and sent over WebSocket
- Results come back as promises
The core client library (~5KB) is served with immutable caching and changes path on each deploy for automatic cache busting.
Key features
- Zero-config client -- just
importfrom a URL - Vite integration --
npm run devstarts everything, types auto-generated - Path-based imports --
import greet from ".../greet" - Static assets -- serve HTML, CSS, and images alongside your API
- Client storage -- access D1, R2, KV directly from the browser
- Classes -- remote instantiation with Comlink-style proxies
- Streaming -- ReadableStream and AsyncIterator support
- Shared exports -- cross-client shared state via Durable Objects
- TypeScript -- precise types generated at build time with oxc-parser
- Rich serialization -- Date, Map, Set, BigInt, URL, TypedArrays, and more
- Single config -- everything in
package.json,wrangler.tomlis auto-generated