Edit this page

Introducing vike-server

We (Joël, Dani, and Rom) have been working on a new Vike extension vike-server which can integrate Vite with any server (Express.js, Hono, Fastify, Elysia, H3, ...) and any deployment (VPS, Netlify, Cloudflare, Vercel, ...).

With vike-server you get:

  • Server code transpiled by Vite (say goodbye to ts-node/tsx/vavite and hello to Vite utilities such as import.meta.env)
  • Zero-config (Vike is automatically added to your server)
  • HMR (no more full server reloads)

We've been beta testing it for months and it's now stable and released as 1.0.0 — you can use it for production.

Unsurprisingly, using Vite to transpile server code was one of the most requested features. In fact, it was Vike's last significant shortcoming: Vike can now be considered a full-fledged framework. We're a lot closer to releasing vike@1.0.0!

You can use vike-server but you don't have to:

  • If you fully pre-render your app (SSG) then you don't need vike-server.
  • If you have unusual requirements, you can keep manually integrating your server.

This follows Vike's philosophy that Vike extensions are all optional: use vike-server for an easy integration or, if you prefer, manually integrate the server for full control.

Zero-config

This is how it looks like:

// server/index.js
 
import express from 'express'
import { apply } from 'vike-server/express'
import { serve } from 'vike-server/express/serve'
 
function startServer() {
  const app = express()
  apply(app)
  return serve(app, { port: 3000 })
}
 
export default startServer()

Where:

  • apply() installs the middleware of Vike and Vike extensions.
  • serve() attaches your server to Node.js, Cloudflare, Vercel, Deno, Bun, Netlify, ...

    serve() enables you to define a single server entry while being able to target multiple environments (e.g. Node.js and Cloudflare have different server attachment styles).

Vike is automatically added to your server so that you don't need to manually integrate renderPage() anymore.

There is still some boilerplate code, but we're also working on a zero-config setup.

You can learn more at Integration > Server.

HMR

If you change a server file, the server code is automatically updated: the next HTTP response will be generated by the latest code. No more full server reload required.

This is experimental and doesn't always work: vike-server sometimes still triggers a full server reload.

If HMR isn't what you want (for example if you modify the database connection) you can manually trigger a full server reload by pressing r + enter.

Getting started

See Integration > Server to get started.

Releasing 1.0

We are a lot closer to releasing vike@1.0.0. Our roadmap is:

  • Implementing the handful of feature requests that are blocking.
  • Lot's of polishing. (This will introduce several minor breaking changes.)

    Our polishing work includes type safe routing.

We expect Vike to stay on 1.x.x for a (very) long time. One of Vike's unique characteristics is its inherently stable core (because it's agnostic; see Overview > Why Vike > Architecture). We want to double down on that.

Beyond stability, we're working on making Vike feature-complete (no known blockers) and highly polished (state-of-the-art DX).

Vite's Environment API

The vike-server extension will increasingly leverage Vite's new Environment API. To understand what it unlocks see: Vite 6 is a groundbreaking release.

Sharing with other frameworks

Most of what we've built is agnostic to Vike.

So why not share our work? That's what we aim to do and we're in talks with other Vite-based frameworks and deployment providers.

Right now, each framework is reinventing the wheel — despite the complexity involved. There's a clear need for a shared server infrastructure that many frameworks can rely on.

See also