Vike Server Integration (Deprecated)

1.0.25 · deprecated · verified Sun Apr 19

The `vike-server` package historically provided utilities for integrating Vike with various Node.js server frameworks like Express.js or Hono, enabling server-side rendering (SSR), hot module replacement (HMR) for server code, and zero-configuration setups with Vite. It aimed to transpiles server code with Vite, eliminating the need for separate tools like `ts-node`. However, `vike-server` (current version 1.0.25) is now deprecated. Vike applications should instead leverage the built-in `+server.js` convention for flexible server integration or migrate to `vike-photon` for advanced edge and serverless deployments. Vike itself, the meta-framework that `vike-server` extended, is currently in a stable 1.x.x release series, focusing on a robust, unopinionated foundation for building web applications with SSR, routing, and data loading atop Vite, and is known for its stable core and gradual evolution.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how `vike-server` was typically used to integrate Vike with an Express.js server, including its now-deprecated `apply` and `serve` functions. This setup enables SSR and asset serving for Vike applications.

import express from 'express';
import { apply, serve } from 'vike-server/express'; // DEPRECATED - see warnings

async function startServer() {
  const app = express();

  // Apply Vike middleware to Express
  // This would integrate Vite's dev server in dev mode
  // and serve Vike's production build in production.
  await apply(app);

  // Start the server
  const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;
  const server = await serve(app, { port });

  console.log(`Server running at http://localhost:${port}`);
  console.warn('WARNING: vike-server is deprecated. Migrate to +server.js or vike-photon.');
  return server;
}

startServer();

// Example Vike page configuration (for context, not part of vike-server)
// pages/index/+Page.js
/*
export { Page }
function Page() {
  return <h1>Hello, Vike!</h1>
}
*/

// Example vite.config.js (for context)
/*
import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'

export default {
  plugins: [react(), vike()],
};
*/

view raw JSON →