Vike logo

Vike

A highly flexible, do-it-yourself React framework builder based on Vite (formerly vite-plugin-ssr).

npm install vike
5.4K49.4K/weekv0.4.2471.47 MBMIT71 issues
Last updated: 2025-11-18
Star history chart for vikejs/vike

TL;DR

A modular frontend architecture that lets you build your own framework on top of Vite.

Provides the building blocks for Server-Side Rendering (SSR) and Static Site Generation (SSG) without locking you into a specific server or deployment platform.

Why Vike?

Vike (formerly vite-plugin-ssr) serves a distinct audience: developers who want the benefits of a modern framework (SSR, hydration, routing) but refuse to accept the "black box" constraints of Next.js or Remix. It is less of a framework and more of a "framework builder" or architectural middleware. It allows you to manually wire up your React app to any Node.js server (Express, Fastify, Hono, NestJS) or edge environment (Cloudflare Workers, Vercel Edge).

  • Architectural Freedom: You own the server.js file. There is no "Next.js way" to run middleware; you just write standard Express/Fastify middleware.
  • Vite Native: It doesn't wrap Vite; it is a Vite plugin. You have full access to vite.config.js without awkward overrides.
  • Progressive Adoption: You can migrate an existing SPA to SSR incrementally, route by route.
  • Framework Agnostic: While this profile focuses on React, Vike supports Vue, Svelte, and Solid, making it ideal for monorepos with mixed tech stacks.
  • Control: You explicitly define how pages are rendered to HTML, giving you granular control over <head> tags, hydration strategies, and state serialization.

Code Snippet

Vike (V1 design) uses a file-system routing convention based on + files. This explicitness separates concerns clearly between data fetching and UI rendering.

// 1. pages/movie/@id/+data.js
// This runs on the server (or client during navigation) to fetch data
export async function data(pageContext) {
  const { id } = pageContext.routeParams
  const response = await fetch(`https://api.movies.com/${id}`)
  const movie = await response.json()
  
  // This data is passed to the page component
  return { movie }
}

// 2. pages/movie/@id/+Page.jsx
// The React component receives the data
import React from 'react'

export function Page({ data }) {
  const { movie } = data
  return (
    <div>
      <h1>{movie.title}</h1>
      <p>Release Date: {movie.releaseDate}</p>
      <img src={movie.poster} alt={movie.title} />
    </div>
  )
}

// 3. pages/movie/@id/+Head.jsx
// Manage SEO tags specifically for this route
export function Head({ data }) {
  return (
    <>
      <title>{data.movie.title}</title>
      <meta name="description" content={data.movie.summary} />
    </>
  )
}

Pros and Cons

No library is perfect; understanding the trade-offs is key to selecting the right tool.

Pros

  • Zero Vendor Lock-in: deploy anywhere that runs JavaScript. You are not tied to Vercel or any specific infrastructure provider's primitives.
  • Integration: easier to integrate into existing complex backends (e.g., a legacy Express monolith) than Next.js.
  • Transparency: debugging is straightforward because you own the server entry point and the HTML rendering logic.

Cons

  • Setup Complexity: requires more boilerplate code to get started. You often have to manually set up the server entry, error handling, and data hydration logic.
  • Smaller Ecosystem: fewer "plug-and-play" integrations compared to the massive Next.js ecosystem. You might need to write your own wrappers for auth or analytics.
  • Mental Load: because you can configure everything, you have to make more decisions about architecture than with opinionated frameworks.

Comparison with Other Frameworks

The table below outlines the positioning differences between Vike and other popular React frameworks:

LibraryDesign PhilosophyBest ForPain Points
VikeMiddleware
A Vite plugin that adds SSR capabilities to any server.
Custom Architecture
Teams needing deep integration with custom backends (Express/Java/Go) or micro-frontends.
Boilerplate
Initial setup and maintenance of "glue code" is higher.
Next.jsFull Platform
A complete, opinionated OS for the web.
Standard Apps
Most greenfield projects where speed-to-market is key.
Black Box
Hard to customize internals; heavily tied to Vercel's hosting model.
RemixWeb Standards
Focus on HTTP and browser fundamentals.
SaaS / Dashboard
Apps requiring robust data mutation and form handling.
Opinionated
While flexible, it still enforces a specific router and server adapter pattern.

Verdict: When to Adopt

Choose Vike if you are an architectural purist or have strict infrastructure requirements that prevent you from using Next.js (e.g., you must serve the frontend from a specific Java backend, or you need to use a specific Node.js web server framework like Fastify). It is the best choice for teams that want the "Vite Developer Experience" but need full control over the server-side rendering pipeline.