Registry / web-framework / vitepress

vitepress

JSON →
library1.6.4jsnpmunverified

VitePress is a highly performant static site generator (SSG) powered by Vite and Vue.js, primarily designed for creating documentation websites, blogs, and content-centric static sites. It leverages Vite for an exceptional developer experience, offering instant server starts and lightning-fast hot module reloading (HMR). The current stable version is 1.6.4, with active development progressing towards a 2.x release, which is currently in alpha and expected to bring significant architectural enhancements. VitePress distinguishes itself through its markdown-first approach, allowing direct embedding of Vue components within Markdown files, robust theming capabilities, and a focus on generating extremely fast, SEO-friendly static assets. It serves as the foundation for the official documentation of Vite, Rollup, and Vue itself, highlighting its stability and performance for critical projects. The project maintains a regular release cadence for minor and patch versions on the stable branch, with frequent alpha updates for the next major iteration, reflecting continuous improvement and feature additions.

npm install vitepress
INSTALL
IMPORT
SIG · VITEPRESS
V
vitepress
web-frameworkjavascriptv1.6.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

defineConfig
✓ import { defineConfig } from 'vitepress'
✗ const defineConfig = require('vitepress')
Used in `.vitepress/config.ts` for type-safe configuration. VitePress config files should be ESM.
useData
✓ import { useData } from 'vitepress'
A Vue Composition API composable for accessing page-specific and site-wide data in theme components.
withBase
✓ import { withBase } from 'vitepress'
A helper function to prepend the site's `base` path to a URL, essential for handling assets and links correctly, especially when deploying to a sub-directory.
DefaultTheme
✓ import DefaultTheme from 'vitepress/theme'
Used when extending the default theme in a custom theme entry file (`.vitepress/theme/index.ts`).

This quickstart demonstrates a minimal VitePress project setup with a `package.json`, basic site configuration (`.vitepress/config.ts`), and a homepage (`docs/index.md`). It includes scripts for development, build, and preview, and configures navigation, sidebar, and a hero section.

{ "name": "my-docs", "type": "module", "scripts": { "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", "docs:preview": "vitepress preview docs" }, "devDependencies": { "vitepress": "^1.0.0-rc.x", "vue": "^3.4.0" } } // .vitepress/config.ts import { defineConfig } from 'vitepress' export default defineConfig({ title: 'My Awesome Docs', description: 'A VitePress Site', base: process.env.VITEPRESS_BASE ?? '/', themeConfig: { nav: [ { text: 'Home', link: '/' }, { text: 'Guide', link: '/guide/' } ], sidebar: [ { text: 'Guide', items: [ { text: 'Introduction', link: '/guide/introduction' }, { text: 'Getting Started', link: '/guide/getting-started' } ] } ], // Add social links if needed // socialLinks: [ // { icon: 'github', link: 'https://github.com/vuejs/vitepress' } // ], footer: { message: 'Released under the MIT License.', copyright: 'Copyright © 2024-present John Doe' } } }) <!-- docs/index.md --> --- layout: home hero: name: "My Awesome Project" text: "A VitePress site example." tagline: My great project tagline actions: - theme: brand text: Get Started link: /guide/getting-started - theme: alt text: View on GitHub link: https://github.com/your-org/your-repo --- ## Welcome This is the homepage of my VitePress documentation site. Explore the navigation and sidebar to learn more.
vitepress --version
Debug
Known issues
breakingMigrating from VitePress 0.x to 1.x involves significant breaking changes. Key changes include a restructured `sidebar` option (children key renamed to `items`), `home: true` in frontmatter becoming `layout: home`, and removal of `repo`, `editLinks` from theme config in favor of more flexible APIs.
fix
Refer to the official VitePress migration guide from 0.x to 1.x and update your configuration and theme files accordingly.
affects: >=1.0.0
breakingVitePress 2.x (currently in alpha) introduces further architectural changes. Configurations are ESM-only, and Vue 3 compatibility is enforced. The theme API is redesigned, making v1.x themes incompatible.
fix
For new projects, start with the latest 2.x alpha. For existing v1.x projects, anticipate a significant migration effort, reviewing the v2 changelogs and documentation once a stable release is available.
affects: >=2.0.0-alpha
gotchaEnvironment variables (`process.env.VITE_APP_KEY`) are not directly accessible in the VitePress configuration file (`.vitepress/config.ts`) during build. The config file is evaluated server-side, not client-side.
fix
Use Vite's `loadEnv` helper within your `defineConfig` export function to correctly load environment variables: `export default ({ mode }) => { const env = loadEnv(mode, process.cwd()); return defineConfig({ title: env.VITE_APP_TITLE }); }`. Alternatively, use a package like `dotenv`.
affects: >=0.x
gotchaComponents embedded directly in Markdown files or custom themes must be SSR-compatible due to VitePress's static build process. Direct access to browser-specific APIs (e.g., `window`, `document`) will cause errors during build.
fix
Wrap non-SSR-friendly components or logic in the `<ClientOnly>` built-in component. Ensure browser-specific API calls are made within Vue's `onMounted` or `beforeMount` lifecycle hooks.
affects: >=0.x
gotchaApplying custom global styles may require specific PostCSS configuration to ensure proper style isolation and prevent conflicts, especially with VitePress's default theme styles or when dealing with RTL (right-to-left) layouts.
fix
Install `postcss` and configure `docs/postcss.config.mjs` to use `postcssIsolateStyles` from `vitepress`. For RTL, additional PostCSS plugins like `rtlcss` might be necessary, configured with specific prefixes (`:where([dir="ltr"])`, `:where([dir="rtl"])`).
affects: >=0.x
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module ...vitepress/config.js not supported
The VitePress configuration file is written in CommonJS syntax (`module.exports = {}`) but VitePress expects an ES Module (`export default {}`).
fix
Rename your config file to `.vitepress/config.mjs` or `.vitepress/config.ts` and rewrite the export statement to `export default defineConfig({...})`.
Error: Failed to resolve import "vitepress/theme" from "/.vitepress/theme/index.ts"
The theme entry file is trying to import `vitepress/theme` but the path is incorrect or the default theme cannot be found.
fix
Ensure `vitepress` is correctly installed. If extending the default theme, use `import DefaultTheme from 'vitepress/theme'` in your `.vitepress/theme/index.ts` file.
ReferenceError: process is not defined
Accessing `process.env` directly in client-side code or SSR-rendered components without proper Vite configuration for environment variables.
fix
Prefix environment variables with `VITE_` (e.g., `VITE_MY_VAR`) and access them via `import.meta.env.VITE_MY_VAR` in client-side code. For server-side config files, use `loadEnv` (see Warnings section).
Upgrade
Version history
1.6.4latest on npm
Audit
Dependencies
postcssrequiredPeer dependency for advanced CSS processing, especially for style isolation or custom PostCSS plugins.
markdown-it-mathjax3optionalPeer dependency for rendering MathJax equations in Markdown. Only needed if mathematical expressions are used.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vitepress — npm install vitepress · libregistry