Registry / web-framework / vike-server

vike-server

JSON →
library1.0.25jsnpmunverified

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.

npm install vike-server
INSTALL
IMPORT
SIG · VIKE-SERVER
V
vike-server
web-frameworkjavascriptv1.0.25
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

apply
✓ import { apply } from 'vike-server/express'
✗ const { apply } = require('vike-server/express')
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`.
serve
✓ import { serve } from 'vike-server/express/serve'
✗ import { serve } from 'vike-server/express'
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`.
* as ExpressVikeServer
✓ import * as ExpressVikeServer from 'vike-server/express'
Accesses all exports from the Express integration. This entire module is deprecated.

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()], }; */
Debug
Known issues
breaking`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.
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`.
affects: >=1.0.0
breakingOlder 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.
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`.
affects: <1.0.0
gotchaVike 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`.
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).
affects: >=0.4.x
breakingRecent 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.
fix
Upgrade your Node.js environment to version 20 or higher. Consider using `nvm` or `volta` to manage Node.js versions.
affects: >=0.4.239
Errors
Common errors & fixes
Error: Cannot find module 'vike-server/express' from 'your-server-file.js'
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.
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`.
TypeError: Cannot read properties of undefined (reading 'pageContext')
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.
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`.
Upgrade
Version history
1.0.25latest on npm
Audit
Dependencies
vikerequiredCore Vike framework, required for any Vike application.
viterequiredUnderlying build tool and dev server, essential for Vike operation.
Agent activity
6 hits · last 30 days
node
6
Resources
vike-server — npm install vike-server · libregistry