Quick Start
Get up and running with VitePress in just a few minutes. This guide will walk you through installation, project setup, and your first dev server.Try It Online
Want to try VitePress before installing? You can experiment directly in your browser: Open VitePress on StackBlitzInstallation
Prerequisites
Before installing VitePress, ensure you have:
- Node.js version 18 or higher
- A package manager (npm, pnpm, yarn, or bun)
- A text editor (VS Code recommended)
Install VitePress
VitePress can be installed as a development dependency in any project:
VitePress is an ESM-only package. Make sure your
package.json contains "type": "module", or use .mjs/.mts file extensions for your config files.Project Structure
After running the setup wizard, your project will have this structure:Understanding the Config File
The config file (.vitepress/config.js) controls your site’s behavior:
.vitepress/config.js
The
defineConfig helper provides TypeScript intellisense even in JavaScript files.Development Commands
The setup wizard adds these npm scripts to yourpackage.json:
package.json
Start Development Server
Launch the dev server with hot module replacement:http://localhost:5173. Open this URL in your browser to see your site.
Build for Production
Generate static HTML for production:.vitepress/dist by default.
Preview Production Build
Test your production build locally:http://localhost:4173 by default.
Using VitePress CLI Directly
You can also invoke VitePress commands directly without npm scripts:- dev
- build
- preview
- init
Start the development server:Options:
--port <port>: Specify port number--host <host>: Specify hostname--force: Force the optimizer to ignore cache
Creating Your First Page
Let’s create a new documentation page:Next Steps
Now that you have VitePress running, explore more features:File-Based Routing
Learn how VitePress maps files to URLs and organize your content
Markdown Extensions
Discover VitePress’s powerful Markdown features and syntax
Theme Configuration
Customize the default theme to match your brand
Deploy Your Site
Learn how to deploy your site to production
Troubleshooting
ESM Module Errors
If you see errors likerequire() of ES Module not supported, add this to package.json:
package.json
.vitepress/config.js to .vitepress/config.mjs.