Skip to Content
Vuesho

CLI

The vuesho and create-vuesho commands.

Vuesho has two commands:

  • create-vuesho creates a site.
  • vuesho runs and builds a site, and copies parts of the UI into it.

create-vuesho

npm create vuesho@latest my-docs

The 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:

OptionWhat it does
--search <name>The search: default, orama-cloud, algolia, meilisearch, typesense or mixedbread
--ai-chat <name>An AI chat: openrouter, llmgateway or inkeep
--i18nTwo languages, en and cn, with a page each
--lintAdds Oxlint to a new project
--pm <name>The package manager: npm, pnpm, yarn or bun
--no-installWrites the dependencies without installing them
--no-gitCreates no Git repository
--forceWrites into a folder that has files, and replaces the files that exist
-y, --yesWrites 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:

package.json
{
  "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:

scripts/create.ts
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:

CommandWhat 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
OptionWhat 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)
--openOpens 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():

scripts/pages.ts
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.ts

The 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
CommandWhat it does
npx vuesho addLists the modules you can copy
npx vuesho add <module...>Copies modules, like layouts/docs or components/card
npx vuesho add themeCopies the whole default theme to <dir>/theme/, src/ui/theme/ by default
OptionWhat 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
--overwriteReplaces 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.