vite-plugin-ssr has been renamed Vike, see migration guide.

Error Handling

Error tracking

Errors can be tracked with pageContext.errorWhileRendering:

// server.js

import { someErrorTracker } from 'some-error-tracker'
import { renderPage } from 'vite-plugin-ssr/server'

app.get('*', async (req, res) => {
  const pageContext = await renderPage({ urlOriginal: req.url })

  // An error occured during server-side rendering
  if (pageContext.errorWhileRendering) {

  // ...

Allowing you to install the error tracking code of services such as Sentry, Bugsnag, Rollbar, or your own custom error tracking.


Vite-plugin-ssr prettifies transpilation errors, such as errors thrown by esbuild and Babel.

While vite-plugin-ssr is careful about not removing relevant information, it may mistakenly do so. In that case create a new GitHub issue. Until a vite-plugin-ssr maintainer fixes the issue you can use the debug flag DEBUG=vps:error.

# Show verbose and original errors
DEBUG=vps:error npm run dev

For even more verbose errors:

# Usually only used by vite-plugin-ssr maintainers
DEBUG=vps:error,vps:log npm run dev