The renderPage() function enables you to embed Vike into any server.
You only need renderPage() if you use SSR, see Optional.
From the perspective of a server, Vike is just a middleware:
You can embed renderPage() into any server.
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).
Bati (make sure to select a server like Express.js, H3, ...)
Usage
The pageContext.httpResponse.body value is the HTML string returned by the
onRenderHtml() hook with additional <script> and <style> tags
automatically injected by Vike.
For HTML streams use httpResponse.pipe() instead of pageContext.httpResponse.body, see HTML Streaming.
Optionally, you can use pageContext.httpResponse.earlyHints for adding early hints (103 Early Hint), see Guides > Preloading > Early hints.
The renderPage() function doesn't depend on Node.js and you can use renderPage() (and therefore embed Vike) anywhere:
Any server environment (Express.js, HatTip, Deno, Fastify, Vite's development server, Node.js's HTTP server, ...)
Any deployment provider (AWS, Cloudflare Workers, Vercel, ...)
When modifying your server, you may need to manually restart your server for your changes to take effect. See #562.
Optional
If you pre-render all your pages then you don't need to use renderPage(), because:
Upon development, Vike automatically embeds itself into Vite's development server ($ vite/$ vite dev).
Upon pre-rendering ($ vite build/$ vike prerender) Vike renders all your pages.
But, if you use Server-Side Rendering (SSR) and you don't pre-render all your pages, then you need a production server and you need to use renderPage() in order to embed Vike into your server. See Guides > Pre-rendering (SSG).