You can embed Vike into any server, and use any server utility.

Alternatively, instead of using a server, you can pre-render your pages and deploy to a static host.

Just a middleware

From the perspective of a server, Vike is just a middleware:

// renderPage() doesn't depend on Node.js and can be used within any JavaScript environment:
// Node.js, AWS, Cloudflare, Vercel, Deno, Bun, Lagon, ...
import { renderPage } from 'vike/server'
 
// Any server: Express.js, Cloudflare Worker, AWS Lambda Function, Fastify, Hono, Nitro, ...
server.addMiddleware({
  method: 'GET',
  route: '*', // catch-all
  async handler(request) {
    const pageContextInit = { urlOriginal: request.url }
    const pageContext = await renderPage(pageContextInit)
    // `body` is the HTML of the page with a route matching pageContextInit.urlOriginal
    const { body, statusCode, headers } = pageContext.httpResponse
    const response = { body, statusCode, headers }
    return response
  }
})

You can embed renderPage() into any server and any deployment environment.

Alternatively, instead of using renderPage(), you can pre-render your pages and remove the need for a production server (and deploy to a static host instead).

You can use:

  • Any server framework (Express, Fastify, Hono, Nitro, HatTip, Koa, Hapi, ...)
  • Any authentication strategy/tool (email/password, OAuth, Auth.js, Passport.js, Grant, Keycloak, Auth0, ...).
  • Any serverless/edge environment (Cloudflare Workers, Vercel, Firebase, AWS Lambda, Google Cloud Functions, Deno Deploy, ...)
  • Any virtual private server (AWS EC2, Google Cloud, ...)
  • Any static host (Cloudflare Pages, GitHub Pages, Netlify, ...)
  • Any server utility (Docker, Nginx, PM2, ...)

Examples:

Non-JavaScript Backend

You can use Vike with a non-JavaScript backend using following setup:

  • Your non-JavaScript backend implements the business logic of data while exposing a REST/GraphQL API.
  • Your Vike app uses that REST/GraphQL API to render your pages to HTML while hydrating them to a rich interactive user interface.

If you want SSR, then you need to deploy two server runtimes: your non-JavaScript runtime as well as a JavaScript server runtime (Node.js/Deno/Bun).

Alternatively, instead of using a server JavaScript runtime, you can pre-render your pages while disabling SSR. In other words: you generate empty HTML shells that you statically deploy (using a static host or your own static assets deployment).

The HTML must be generated by Vike because the UI is completely owned by React/Vue/Solid. You cannot generate the HTML using your non-JavaScript backend: React/Vue/Solid would complain that it doesn't match and completely erase your HTML.

That way, you can use Vike with any backend:

  • Java (Spring, Grails, ...)
  • PHP (Laravel, Symfony, CakePHP, ...)
  • Ruby on Rails
  • Python (Django, Flask, FastAPI, ...)
  • Elixir (Phoenix, ...)
  • Go (Gin, Echo, Fiber, ...)
  • Rust (Actix Web, Rocket, ...)
  • Backend-as-a-Service (Firebase, ..)
  • ...

Example:

HTTPS

In production, Vike is only a server middleware; there is nothing to take into consideration.

If you want to use HTTPS in development as well, then make sure to pass the HTTPS certificates to Vite's dev server.

See also