@lunora/vite
The recommended dev-time experience — codegen, HMR, overlay.
@lunora/vite is a Vite plugin factory. A single lunora() call wires up
codegen, wrangler validation, the error overlay, and the Cloudflare Vite
plugin so vite dev runs your Worker locally with full HMR.
// vite.config.ts
import { lunora } from "@lunora/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [react(), lunora()],
});Options
| Option | Default | Purpose |
|---|---|---|
schemaDir | "lunora" | Directory containing schema.ts + function files |
generatedDir | "lunora/_generated" | Where to emit api.ts, server.ts, dataModel.ts |
apiSpec | "openapi" | API spec emitted into _generated/: "openapi"/"openrpc"/"both"/"none" |
studio | true | Serve the Lunora studio at /__lunora during dev, or false to skip |
cloudflare | true | Pass options to @cloudflare/vite-plugin, or false to skip |
overlay | true | Inject @visulima/vite-overlay for runtime errors, or false to skip |
validateWrangler | true | Cross-check wrangler.jsonc bindings against the schema |
projectRoot | process.cwd() | Override for monorepo setups |
Codegen lifecycle
The plugin watches <schemaDir>/**/*.ts. On any change it parses the
schema with ts-morph, regenerates _generated/*.ts, and the Vite module
graph picks up the new types — your editor sees the change before you can
swap windows.
Wrangler validator
Compares the table tier modifiers in your schema with durable_objects.bindings,
d1_databases, and r2_buckets in wrangler.jsonc. Reports missing
bindings as Vite errors before they explode at deploy.
Studio
During dev the plugin mounts the Lunora studio at /__lunora so you can browse
your schema, data, logs, and advisors without leaving the dev server. Set
studio: false to turn it off.