@xyd-js/next-plugin
v0.0.0-build-0167722-20260922165502
Published
Next.js plugin that builds xyd docs during `next build` and serves them under a subpath of your app — with a spawned `xyd dev` + proxy rewrites in `next dev`
Maintainers
Readme
@xyd-js/next-plugin
xyd docs inside your Next.js app — one deployable, one origin:
your app at /, your docs under /docs.
// next.config.mjs
import { withXyd } from "@xyd-js/next-plugin";
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default withXyd({ docsRoot: "./docs", base: "/docs" })(nextConfig);How it works
next build— runsxyd buildfor the docs project (child process) and merges the static output intopublic/(pages underpublic/docs, hashed assets underpublic/assets— Next servespublic/at the site root). Extensionless docs URLs (/docs/overview) are mapped to the flat.htmlfiles viaafterFilesrewrites, whichnext startand Vercel honor at runtime. A manifest (public/.xyd-docs-manifest.json) tracks the generated files so every rebuild cleans its previous output first.Add the generated paths to your
.gitignore:public/docs/ public/assets/ public/public/ public/.xyd-docs-manifest.jsonnext dev— spawnsxyd dev(bun engine) on an internal port and proxies the mount + xyd's/_xyd/*+/_bun/*internals via rewrites to that origin. App and docs share one URL/port. (Next's rewrite proxy is HTTP-only, so the docs live-reload websocket degrades gracefully — pages and styles still work; refresh manually after edits.)
Which xyd runs?
Same resolution as @xyd-js/vite-plugin:
the command option → a local xyd-js / @xyd-js/cli install → an xyd binary on
PATH. Recommended: npm i -D xyd-js.
Options
Accepts the same options as @xyd-js/vite-plugin (minus outDir): docsRoot
(required), base, enabled, dev, command, env, nodeOptions,
sitemap/robots, timeoutMs, silent, verbose. The mount comes from base
(passed to xyd via XYD_BASENAME) or the docs' own advanced.basename — the docs
side wins when both are set (they must match).
