Agnostic Middleware

From an architectural point of view, vite-plugin-ssr is just a server middleware that can be used in any server environment.

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

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

dist/server/importBuild.js helps bundlers discover the entire dependency tree.



We can integrate vite-plugin-ssr in any server environment we want.

Edit this page