npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

@zerva/vite

v0.81.7

Published

🌱 Zerva and Vite

Downloads

414

Readme

🌱 @zerva/vite

npm version License: MIT

Seamlessly integrate Vite development server with Zerva

This package provides a bridge between Vite's powerful development server (with HMR, fast builds, and modern tooling) and Zerva's server-side capabilities, giving you the best of both worlds for full-stack development.

✨ Features

  • πŸ”₯ Hot Module Replacement (HMR) in development mode
  • ⚑ Lightning-fast Vite development server integration
  • πŸ“¦ Production-ready static file serving with caching
  • πŸš€ Multi-page application support
  • πŸ”„ Automatic mode switching between development and production
  • 🎯 Zero configuration for most use cases
  • πŸ› οΈ TypeScript support out of the box

πŸ“¦ Installation

npm install @zerva/vite vite
# or
pnpm add @zerva/vite vite
# or
yarn add @zerva/vite vite

πŸš€ Quick Start

Basic Setup

import { serve } from '@zerva/core'
import { useHttp } from '@zerva/http'
import { useVite } from '@zerva/vite'

// Setup HTTP server
useHttp({
  port: 3000,
  openBrowser: true,
})

// Integrate Vite
useVite()

// Start the server
serve()

That's it! Your Vite project will be served with HMR in development mode, and as optimized static files in production.

βš™οΈ Configuration

Configuration Options

useVite({
  // Path to your Vite project (default: process.cwd())
  root: './frontend',
  
  // Output directory for built files (default: './dist_www')
  www: './dist',
  
  // Vite mode: 'development' | 'production' (auto-detected)
  mode: 'development',
  
  // Enable asset caching in production (default: true)
  cacheAssets: true,
  
  // Optional logging configuration
  log: { level: 'info' }
})

Environment Variables

  • ZERVA_DEVELOPMENT: Set to enable development mode
  • ZERVA_VITE: Alternative way to enable Vite development mode
  • NODE_ENV: Affects mode detection

πŸ—οΈ Project Structure

Recommended Structure

For optimal organization, keep all source code in a src folder with Zerva server code in src/zerva:

my-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/     # Frontend components
β”‚   β”œβ”€β”€ pages/         # Frontend pages
β”‚   β”œβ”€β”€ styles/        # CSS/styling files
β”‚   β”œβ”€β”€ utils/         # Shared utilities
β”‚   β”œβ”€β”€ zerva/         # Zerva server code
β”‚   β”‚   β”œβ”€β”€ index.ts   # Server entry point
β”‚   β”‚   └── modules/   # Server modules
β”‚   └── main.ts        # Frontend entry point
β”œβ”€β”€ public/            # Static assets
β”œβ”€β”€ index.html         # Main HTML template
β”œβ”€β”€ package.json
β”œβ”€β”€ vite.config.ts
└── dist_www/         # Built frontend files (auto-generated)

Configuration Example

Server (src/zerva/index.ts):

import { serve } from '@zerva/core'
import { useHttp } from '@zerva/http'
import { useVite } from '@zerva/vite'

useHttp({ port: 3000 })

useVite({
  root: '.',           // Project root (where vite.config.ts is)
  www: './dist_www'    // Where built files go
})

serve()

Vite Config (vite.config.ts):

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' // or your preferred framework

export default defineConfig({
  plugins: [vue()],
  root: '.',                    // Project root
  build: {
    outDir: 'dist_www',         // Match the 'www' path in useVite()
  },
  server: {
    // Development server will be handled by Zerva
  }
})

πŸ”„ Development vs Production

Development Mode

  • Vite dev server runs with HMR
  • Instant updates and fast builds
  • Source maps and debugging support
  • Automatic reload on file changes

Production Mode

  • Serves pre-built static files
  • Aggressive caching with max-age=31536000, immutable
  • Optimized asset delivery
  • Multi-page app routing support

🌐 Multi-Page Applications

The package includes built-in support for multi-page applications:

// vite.config.ts
export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        admin: resolve(__dirname, 'admin/index.html'),
        dashboard: resolve(__dirname, 'dashboard/index.html'),
      }
    }
  }
})

Routes like /admin/settings will automatically serve /admin/index.html.

πŸ› οΈ Advanced Usage

Custom Vite Plugin Integration

import { zervaMultiPageAppIndexRouting } from '@zerva/vite'

// In your vite.config.ts
export default defineConfig({
  plugins: [
    vue(),
    zervaMultiPageAppIndexRouting(), // Already included automatically
    // Your other plugins...
  ]
})

Conditional Development Setup

import { useVite } from '@zerva/vite'

// Only use Vite integration in development
if (process.env.NODE_ENV === 'development') {
  useVite({
    root: './src-web',
    cacheAssets: false, // Disable caching in dev
  })
}

πŸ§ͺ Testing

The package includes comprehensive tests covering:

  • Development and production modes
  • Configuration validation
  • Multi-page routing
  • Error handling
  • Asset caching

Run tests with:

pnpm test

πŸ“š Examples

Check out the examples directory in the main Zerva repository:

🀝 Related Packages

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™‹β€β™‚οΈ Support