{"id":12365,"library":"vike-server","title":"Vike Server Integration (Deprecated)","description":"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.","status":"deprecated","version":"1.0.25","language":"javascript","source_language":"en","source_url":"https://github.com/vikejs/vike-server","tags":["javascript","typescript"],"install":[{"cmd":"npm install vike-server","lang":"bash","label":"npm"},{"cmd":"yarn add vike-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add vike-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core Vike framework, required for any Vike application.","package":"vike","optional":false},{"reason":"Underlying build tool and dev server, essential for Vike operation.","package":"vite","optional":false}],"imports":[{"note":"This import path is deprecated. The `apply` function, which integrated Vike middleware, is now part of `vike-photon` (e.g., `@photonjs/express`) or handled implicitly by `+server.js`.","wrong":"const { apply } = require('vike-server/express')","symbol":"apply","correct":"import { apply } from 'vike-server/express'"},{"note":"This specific utility for attaching the server to Node.js/edge environments is deprecated. Similar functionality is available via `vike-photon` (e.g., `@photonjs/express`) or direct server setup with `+server.js`.","wrong":"import { serve } from 'vike-server/express'","symbol":"serve","correct":"import { serve } from 'vike-server/express/serve'"},{"note":"Accesses all exports from the Express integration. This entire module is deprecated.","symbol":"* as ExpressVikeServer","correct":"import * as ExpressVikeServer from 'vike-server/express'"}],"quickstart":{"code":"import express from 'express';\nimport { apply, serve } from 'vike-server/express'; // DEPRECATED - see warnings\n\nasync function startServer() {\n  const app = express();\n\n  // Apply Vike middleware to Express\n  // This would integrate Vite's dev server in dev mode\n  // and serve Vike's production build in production.\n  await apply(app);\n\n  // Start the server\n  const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;\n  const server = await serve(app, { port });\n\n  console.log(`Server running at http://localhost:${port}`);\n  console.warn('WARNING: vike-server is deprecated. Migrate to +server.js or vike-photon.');\n  return server;\n}\n\nstartServer();\n\n// Example Vike page configuration (for context, not part of vike-server)\n// pages/index/+Page.js\n/*\nexport { Page }\nfunction Page() {\n  return <h1>Hello, Vike!</h1>\n}\n*/\n\n// Example vite.config.js (for context)\n/*\nimport react from '@vitejs/plugin-react'\nimport vike from 'vike/plugin'\n\nexport default {\n  plugins: [react(), vike()],\n};\n*/","lang":"typescript","description":"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."},"warnings":[{"fix":"Remove `vike-server` from dependencies. For server integration, implement `+server.js` files as documented on vike.dev, or install and configure `vike-photon` (e.g., `npm install vike-photon @photonjs/express`). Refer to the official Vike migration guides for `+server` and `vike-photon`.","message":"`vike-server` is officially deprecated. Modern Vike applications should migrate to using the `+server.js` convention for server-side routing and API endpoints, or utilize the `vike-photon` package for robust edge deployments. Continued use of `vike-server` is discouraged and may lead to compatibility issues with newer Vike and Vite versions.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure you are using `vike-server/express` (if staying on `vike-server`) or, preferably, migrate to `vike-photon` which provides framework-specific packages like `@photonjs/express`.","message":"Older versions of Vike's server integration (prior to `vike-server` and `vike-photon`) used `vike-node/connect`, which was replaced by `vike-node/express`. If migrating from a very old setup, this change is relevant.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Migrate your project to use the 'plus files' convention. For example, rename `index.page.js` to `+Page.js` and `_default.page.server.js` to `+onRenderHtml.js` (or similar for other hooks).","message":"Vike introduced 'plus files' (`+Page.js`, `+server.js`, `+onBeforeRender.js`) as the recommended convention for defining pages and server-side logic, replacing the older `.page.js` suffixes. While `vike-server` itself didn't directly control this, the deprecation aligns with Vike's overall move towards 'plus files' and away from implicit server integration via `vike-server`.","severity":"gotcha","affected_versions":">=0.4.x"},{"fix":"Upgrade your Node.js environment to version 20 or higher. Consider using `nvm` or `volta` to manage Node.js versions.","message":"Recent versions of Vike (and by extension its server tooling) require Node.js 20 or above. Using older Node.js versions may lead to runtime errors or compatibility issues.","severity":"breaking","affected_versions":">=0.4.239"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify `vike-server` is listed in your `package.json` and installed. If you intend to use `vike-photon` or `+server.js`, ensure `vike-server` is uninstalled and your server entry point is updated according to the Vike migration guides for `+server` or `vike-photon`.","cause":"The `vike-server` package (or its framework-specific entry point) is either not installed, or you are attempting to use it after having migrated to `vike-photon` or `+server.js` and removed it.","error":"Error: Cannot find module 'vike-server/express' from 'your-server-file.js'"},{"fix":"Ensure `vike-server` (or its replacement `vike-photon`/`+server.js`) is correctly initialized and applied to your server framework. Check Vike's documentation on `pageContext` and server integration for the correct setup, especially if you recently upgraded Vike or are migrating away from `vike-server`.","cause":"This error often indicates an issue with Vike's server-side rendering setup, where `pageContext` is not properly populated or passed. It could be due to an incomplete `vike-server` setup, or a misconfiguration after migrating away from it.","error":"TypeError: Cannot read properties of undefined (reading 'pageContext')"}],"ecosystem":"npm"}