API
Everything the package exports, and everything it does that can surprise you.
The middleware
edityy({ tag, nonce, root, save, allowedHosts }) // returns a (req, res, next) middlewaretagdefaults to<script src="/__edityy/edityy.js" defer></script>. Pass your own if you need a different attribute set.nonceadds a nonce to the tag, for a page with a strictscript-srcCSP. Give a string, or a function(req, res) => stringwhen your app makes a new nonce for each response.rootis where.edityy/changes.jsonis written. It defaults toprocess.cwd().save: falseturns off the save endpoint and the variation endpoint.allowedHostsnames more hosts the save endpoint takes, besideslocalhostand IP addresses. A leading dot also takes the subdomains.truetakes every host.
The Vite plugin takes the same options, and adds one of its own: source: false turns off the data-edityy-src attribute.
The exports
launcheris the launcher script, as a string.ASSET_PATHis/__edityy/edityy.js, andTAGis the default script tag.inject(body, tag?)injects the tag into an HTML string yourself.changesRoute({ root, allowedHosts })is the save endpoint as a fetch-style route handler.variationsRoute({ root, allowedHosts })is the variation endpoint asGET,POSTandDELETEroute handlers.writeChanges(payload, root?)writes the changes file yourself.CHANGES_PATHandCHANGES_FILEare the endpoint path and the file name.edityy/clientis the browser bootstrap that mounts the launcher, for frameworks that inject client modules.edityy/injectis the main module under a second name, for frameworks that render the script tag themselves.edityy/viteis the Vite plugin.
The events
edityy:launcher-click is dispatched on window each time the launcher is clicked, for a host app that wants to know.
The known limits
- Dev-only. This is not a proxy and not a production server plugin. Install it as a dev dependency and keep it out of your production build.
- Streamed HTML is held only up to
</head>. A chunked response gets the tag before</head>, and everything after it streams through. If no</head>arrives in the first 256 KB, the page is sent unchanged. - A strict
script-srcCSP blocks the tag unless you pass the page's nonce asnonce. - Google Fonts need network access. A page whose CSP blocks
api.fontsource.org,fonts.googleapis.comorfonts.gstatic.comshows only its own fonts. - It fails open. An error inside the middleware is swallowed, and your page is served unchanged, rather than taking the dev server down.
The command
terminal
edityy mcp [--root <dir>]The command has one subcommand. mcp serves the saved edits to a coding agent over MCP, on stdio.
Edityy