Error Handling

Error tracking

Errors can be tracked with pageContext.errorWhileRendering:

// server.js

import { someErrorTracker } from 'some-error-tracker'
import { renderPage } from 'vike/server'

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

  // An error occurred 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.


Vike prettifies transpilation errors, such as errors thrown by esbuild and Babel.

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

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

For even more verbose errors:

# Usually only used by Vike maintainers
DEBUG=vike:error,vike:log npm run dev