Agnostic Middleware

From an architectural point of view, vite-plugin-ssr is just a server middleware. It's versatile and we can use it any server environment we want.

const { createPageRenderer } = require('vite-plugin-ssr')
const renderPage = createPageRenderer(/* ... */)

// `app` can be any server framework such as Express.js/Fastify/Koa/Hapi/...
app.get('*', async (req, res) => {
  // `renderPage()` can also be used in serverless environments such as
  // Cloudflare Workers and Vercel
  const pageContext = await renderPage({ url: req.url })

Server Bundling

Some deploy services, such as Cloudflare Workers, bundle the entire server-side code into a single file.

To enable server bundling we load a special file dist/server/importBuild.js.



We can use vite-plugin-ssr with any deploy strategy/service we want.