Edit this page

[Warning] Wrong setup

Vite should only be loaded in development (or when building). Loading it in production is unnecessary and significantly bloats the production process.

In production:

  • Make sure you don't load the vite package nor Vike's Vite plugin.
  • Make sure you don't call createDevMiddleware(). (The development middleware isn't needed in production.)

    You can import createDevMiddleware in production, but make sure you don't call it.

    // Environment: production
    import { createDevMiddleware } from 'vike/server' // ✅ You can import it
    createDevMiddleware()                             // ❌ You shouldn't call it

In development, if you use a server without vike-server (i.e. you manually integrate your server), you must use createDevMiddleware() in order to add the development middleware to your server. (If you use vike-server, the development middleware is added automatically and you don't need to use createDevMiddleware().)

See also