CLI
The vuesho and create-vuesho commands.
Vuesho has two commands:
create-vueshocreates a site.vueshoruns and builds a site, and copies parts of the UI into it.
create-vuesho
npm create vuesho@latest my-docsThe command asks where the site goes, and whether to install the dependencies and start the dev server. The other choices are flags, and --yes skips the questions:
| Option | What it does |
|---|---|
--search <name> | The search: default, orama-cloud, algolia, meilisearch, typesense or mixedbread |
--ai-chat <name> | An AI chat: openrouter, llmgateway or inkeep |
--i18n | Two languages, en and cn, with a page each |
--lint | Adds Oxlint to a new project |
--pm <name> | The package manager: npm, pnpm, yarn or bun |
--no-install | Writes the dependencies without installing them |
--no-git | Creates no Git repository |
--force | Writes into a folder that has files, and replaces the files that exist |
-y, --yes | Writes the site to the given folder or my-docs, and installs the dependencies |
Without --pm, the command uses the package manager of the project's lockfile, or else the one that runs it.
In a folder with a package.json, the command offers to add the site to that project, in a docs folder, with these scripts:
{
"scripts": {
"docs:dev": "vuesho dev docs",
"docs:build": "vuesho build docs",
"docs:preview": "vuesho preview docs"
}
}At a workspace's root, the site becomes a new package in docs. With --yes, pass . as the folder to add the site to the project you're in.
With a search service, vuesho.config.ts has placeholder IDs for it. Its API keys, and an AI chat's, are listed without values in .env.local.
create() from create-vuesho does the same in a script:
import { create } from "create-vuesho";
await create({ dir: "my-docs", search: "algolia", install: true });vuesho
vuesho runs Vite with the Vuesho plugin, so a site needs no vite.config.ts. Each command takes the site's folder, the current one by default:
| Command | What it does |
|---|---|
vuesho dev [root] | Starts the dev server |
vuesho build [root] | Builds the site into .output |
vuesho preview [root] | Serves the build |
vuesho run <script> [root] | Runs a script that reads the site, without a server |
vuesho prepare [root] | Writes the files that editors and the type check read, without a server |
vuesho add [module...] | Copies parts of the UI into the site, as below |
| Option | What it does |
|---|---|
--host [host] | The host to listen on, or every address without a value (dev, preview) |
--port <port> | The port to listen on (dev, preview) |
--open | Opens the site in the browser (dev, preview) |
--base <path> | The site's base path |
--mode <mode> | Vite's mode |
Running a Script
vuesho run loads the site like vuesho dev, then runs a script that reads the site with getSiteContext():
import { getSiteContext } from "vuesho/config";
import type app from "../vuesho.config";
const ctx = getSiteContext<typeof app>();
for (const page of ctx.getPages()) console.log(page.url, page.data.title);vuesho run scripts/pages.tsThe context is the one plugins receive, described in Plugin API. A script can't import nitro/*. For work after a build, use a plugin's build hook, as Build Output shows.
vuesho add
vuesho add copies UI modules into your project, where you can edit them. It runs in the site's folder:
npx vuesho add layouts/docs/slots/sidebar| Command | What it does |
|---|---|
npx vuesho add | Lists the modules you can copy |
npx vuesho add <module...> | Copies modules, like layouts/docs or components/card |
npx vuesho add theme | Copies the whole default theme to <dir>/theme/, src/ui/theme/ by default |
| Option | What it does |
|---|---|
--from <package> | Copies from a package built on Vuesho, like @vuesho/openapi, to <dir>/<package> |
--dir <path> | Where modules go, src/ui by default |
--overwrite | Replaces files that exist |
vuesho add downloads the sources of the installed version from GitHub, so it needs the network. A module that the package doesn't export comes with the copy that imports it, and a package that a copy needs is installed. When you copy another module later, the command rewrites your project's imports to use the new copy.
Using a Copy
A copy takes effect once one of your files imports it, and the command warns when none does. A copied Markdown component, like Card, needs a file in src/components/content/ that re-exports it.
Many copies pass an imported type to defineProps(), which Vue's compiler reads with TypeScript, so install typescript in the project.