Skip to main content

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 StackBlitz

Installation

1

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)
Check your Node version:
2

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.
3

Run the Setup Wizard

VitePress includes an interactive setup wizard to scaffold your project:
The wizard will ask you a few questions:

Project Structure

After running the setup wizard, your project will have this structure:
The .vitepress directory is reserved for VitePress configuration, cache, and build output. Add .vitepress/cache and .vitepress/dist to your .gitignore.

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

Start Development Server

Launch the dev server with hot module replacement:
The dev server will start at http://localhost:5173. Open this URL in your browser to see your site.
If port 5173 is already in use, VitePress will automatically try the next available port.

Build for Production

Generate static HTML for production:
Built files will be output to .vitepress/dist by default.

Preview Production Build

Test your production build locally:
The preview server runs at http://localhost:4173 by default.

Using VitePress CLI Directly

You can also invoke VitePress commands directly without npm scripts:
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:
1

Create a new Markdown file

Create docs/getting-started.md:
docs/getting-started.md
2

Add to navigation

Update .vitepress/config.js to include your new page:
.vitepress/config.js
3

View your page

Navigate to http://localhost:5173/getting-started to see your new 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 like require() of ES Module not supported, add this to package.json:
package.json
Or rename your config file from .vitepress/config.js to .vitepress/config.mjs.

Port Already in Use

Specify a different port:

Cache Issues

Clear the cache and restart: