Edit

❌ 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

    If you use +server.js or +serverEntry.js, the development middleware is automatically created — you don't need to use createDevMiddleware() at all. (You only need createDevMiddleware() if you run the server yourself.)

See also