PHPackages                             laravel-ready/laravel-vitepress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. laravel-ready/laravel-vitepress

ActiveLibrary

laravel-ready/laravel-vitepress
===============================

Serve VitePress documentation in Laravel with middleware and authentication support

v1.2.3(5mo ago)1338MITPHPPHP ^8.1CI passing

Since Dec 1Pushed 4mo agoCompare

[ Source](https://github.com/laravel-ready/laravel-vitepress)[ Packagist](https://packagist.org/packages/laravel-ready/laravel-vitepress)[ RSS](/packages/laravel-ready-laravel-vitepress/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (11)Versions (7)Used By (0)

Laravel VitePress
=================

[](#laravel-vitepress)

[![Laravel-VitePress](https://camo.githubusercontent.com/bb4e5e1065f41e6871d1c02155f8fbb3d86dd09b3913ac7ffabf2fab682ae0cd/68747470733a2f2f707265766965772e647261676f6e2d636f64652e70726f2f4c61726176656c52656164792f6c61726176656c2d7669746570726573732e7376673f6272616e643d6c61726176656c)](https://github.com/laravel-ready/laravel-vitepress)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8e2dfc0deefc6680a09000e06d35a2076b9e62577eff09f635f9970022834714/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d72656164792f6c61726176656c2d7669746570726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-ready/laravel-vitepress)[![GitHub Tests Action Status](https://camo.githubusercontent.com/add062a0e6ee944e1e4c13731d1cffa8f92f0c5d7b3d41afecf8254f0ea6bcae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c61726176656c2d72656164792f6c61726176656c2d7669746570726573732f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/laravel-ready/laravel-vitepress/actions?query=workflow%3Atests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/40d151528276847c3781d8abd96453151a2bc701be516a2847da5ed8443ee725/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d72656164792f6c61726176656c2d7669746570726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-ready/laravel-vitepress)[![License](https://camo.githubusercontent.com/95b7a0cda6fd518cac458e441af7ac723768d499b5266af9faeb822e929998fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2d72656164792f6c61726176656c2d7669746570726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-ready/laravel-vitepress)

Serve VitePress documentation in your Laravel application with full middleware support, authentication, and role-based access control.

✨ Features
----------

[](#-features)

- 🚀 Pre-built VitePress documentation (no build step required in production)
- 🔐 Laravel authentication and authorization integration
- 🛡️ Middleware support for route protection
- 👥 Role and permission-based access control (compatible with Spatie Laravel Permission)
- ⚙️ Fully configurable routing
- 📦 Easy installation and publishing
- 🎨 Customizable views and layouts
- 🔒 Path traversal protection
- 🔐 Protected storage by default (docs stored outside `public/` to enforce auth)
- 💾 Cache control headers
- 🌐 Multi-domain support

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x
- Node.js 20+ (for building documentation)

📊 Support Matrix
----------------

[](#-support-matrix)

PHPLaravel 10Laravel 11Laravel 128.1✅❌❌8.2✅✅❌8.3✅✅✅8.4✅✅✅8.5❌❌✅📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require laravel-ready/laravel-vitepress
```

Run the installation command:

```
php artisan vitepress:install
```

This will publish:

- Configuration file to `config/vitepress.php`
- Pre-built documentation assets to `storage/app/vitepress/docs` (protected by default)

Visit `/docs` in your browser to see your documentation.

⚙️ Configuration
----------------

[](#️-configuration)

### Basic Setup

[](#basic-setup)

```
// config/vitepress.php

return [
    'route' => [
        'prefix' => 'docs', // Access at /docs
        'middleware' => ['web'],
    ],
];
```

### Storage Location

[](#storage-location)

By default, documentation is stored in `storage/` to prevent direct file access and ensure authentication is enforced. For public documentation without auth, you can store in `public/`:

```
'assets' => [
    // 'storage' = protected (default), 'public' = directly accessible
    'storage' => 'storage',
    'path' => 'vitepress/docs',
],
```

**Important:** If you use authentication (`auth.enabled = true`), keep `storage` set to `'storage'`. Otherwise users can bypass auth by accessing files directly at `/vitepress/docs/index.html`.

### With Authentication

[](#with-authentication)

Require users to be logged in:

```
'auth' => [
    'enabled' => true,
    'middleware' => ['auth'],
],
```

### With Role-Based Access

[](#with-role-based-access)

Works with [spatie/laravel-permission](https://github.com/spatie/laravel-permission) (optional):

```
'auth' => [
    'enabled' => true,
    'middleware' => ['auth'],
    'roles' => ['admin', 'developer'],
],
```

### With Permission-Based Access

[](#with-permission-based-access)

```
'auth' => [
    'enabled' => true,
    'middleware' => ['auth'],
    'permissions' => ['view-documentation'],
],
```

> **Note:** Role and permission checks use `hasAnyRole()` and `hasAnyPermission()` methods from Spatie Laravel Permission. If the package is not installed, these checks are automatically skipped. The package works without Spatie - you can use basic auth or custom gates instead.

### Custom Domain

[](#custom-domain)

Serve documentation from a subdomain:

```
'route' => [
    'domain' => 'docs.example.com',
    'prefix' => '',
],
```

### Custom Gate

[](#custom-gate)

Define a custom gate for complex authorization:

```
// In AuthServiceProvider
Gate::define('view-documentation', function ($user) {
    return $user->hasActiveSubscription();
});

// config/vitepress.php
'auth' => [
    'enabled' => true,
    'gate' => 'view-documentation',
],
```

🚀 Usage
-------

[](#-usage)

### Accessing Documentation

[](#accessing-documentation)

After installation, your documentation is available at:

```
https://your-app.com/docs
```

### Using the Facade

[](#using-the-facade)

```
use LaravelReady\VitePress\Facades\VitePress;

// Check if VitePress is enabled
if (VitePress::isEnabled()) {
    // ...
}

// Get the documentation URL
$url = VitePress::getRouteUrl();

// Check if current user can access docs
if (VitePress::canAccess()) {
    // Show documentation link
}

// Get configuration
$config = VitePress::getConfig();
$prefix = VitePress::getConfig('route.prefix');
```

### In Blade Templates

[](#in-blade-templates)

```
@if(VitePress::isEnabled() && VitePress::canAccess())
    Documentation
@endif
```

🎨 Customization
---------------

[](#-customization)

### Publishing VitePress Source

[](#publishing-vitepress-source)

To customize the documentation:

```
php artisan vitepress:publish --stubs
```

This will publish VitePress source files to `resources/docs/`.

### Configuration Files

[](#configuration-files)

The VitePress config is split into two files:

FilePurposeEditable?`.vitepress/config.mts`Package-managed (base URL, dotenv)No`.vitepress/config.docs.mts`Your customizations (title, nav, sidebar)YesEdit `config.docs.mts` to customize your documentation. Don't edit `config.mts` - it contains package logic that reads from your `.env` file.

### Building Documentation

[](#building-documentation)

After making changes, rebuild:

```
php artisan vitepress:build
```

### Changing Route Prefix

[](#changing-route-prefix)

Just update your `.env` file:

```
VITEPRESS_ROUTE_PREFIX=documentation
```

Then rebuild:

```
php artisan vitepress:build
```

The base URL is automatically read from your `.env` file - no need to pass environment variables manually.

### Publishing Other Resources

[](#publishing-other-resources)

```
# Publish configuration only
php artisan vitepress:publish --config

# Publish assets only
php artisan vitepress:publish --assets

# Publish views only
php artisan vitepress:publish --views

# Publish everything
php artisan vitepress:publish --all

# Publish everything (force overwrite, useful when package needs updating etc.)
php artisan vitepress:publish --all --force
```

🛠️ Artisan Commands
-------------------

[](#️-artisan-commands)

CommandDescription`vitepress:install`Install the package (publishes config and assets)`vitepress:publish`Publish specific resources`vitepress:build`Build VitePress documentation🔧 Environment Variables
-----------------------

[](#-environment-variables)

```
VITEPRESS_ENABLED=true
VITEPRESS_ROUTE_PREFIX=docs
VITEPRESS_DOMAIN=
VITEPRESS_AUTH_ENABLED=false
VITEPRESS_ALLOWED_ROLES=admin,developer
VITEPRESS_ALLOWED_PERMISSIONS=view-docs
VITEPRESS_GATE=
VITEPRESS_STORAGE=storage
VITEPRESS_ASSETS_PATH=vitepress/docs
VITEPRESS_CACHE_ENABLED=true
VITEPRESS_CACHE_MAX_AGE=3600
```

🔬 Advanced Usage
----------------

[](#-advanced-usage)

### Custom Headers

[](#custom-headers)

Add security or custom headers:

```
'options' => [
    'headers' => [
        'X-Frame-Options' => 'SAMEORIGIN',
        'X-Content-Type-Options' => 'nosniff',
    ],
],
```

### Custom 404 Page

[](#custom-404-page)

```
'options' => [
    'custom_404' => 'errors.docs-404',
],
```

### CORS Support

[](#cors-support)

Enable CORS for API documentation:

```
'options' => [
    'cors_enabled' => true,
],
```

### SPA Fallback

[](#spa-fallback)

The package includes SPA fallback routing by default. Disable it for traditional page routing:

```
'options' => [
    'spa_fallback' => false,
],
```

🧪 Testing
---------

[](#-testing)

```
composer test
```

📝 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance75

Regular maintenance activity

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

160d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8c5a4a2047094867ebe437462b827160e660b5e7bfbad68b57f8d255890d42a?d=identicon)[relliv](/maintainers/relliv)

---

Top Contributors

[![relliv](https://avatars.githubusercontent.com/u/17010054?v=4)](https://github.com/relliv "relliv (38 commits)")

---

Tags

laraveldocumentationdocsvitepress

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/laravel-ready-laravel-vitepress/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-ready-laravel-vitepress/health.svg)](https://phpackages.com/packages/laravel-ready-laravel-vitepress)
```

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

71510.9M66](/packages/laravel-mcp)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
