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

process.env.NODE_ENV

We recommend the following.

In development:

  • Don't set process.env.NODE_ENV, or set it to one of the following values: ['development', 'dev', '', undefined].
  • If you don't use Vite's development server, then add Vite's development middleware to your server (as shown in API > renderPage() > Usage).

In production (and staging):

  • Set process.env.NODE_ENV to a value different than ['development', 'dev', '', undefined], for example 'production' or 'staging'.
  • Don't add Vite's server middleware to your server: it isn't needed in production and would unnecessarily bloat your production server.

process.env.NODE_ENV is a convention to tell libraries whether your app is running in production or development:

While the convention was introduced by Node.js, it's used by libraries regardless whether you use Node.js or not. That's why we recommend to set process.env.NODE_ENV in Edge environments as well.

Vite-plugin-ssr shows a warning if you don't respect the recommendation above:

[vite-plugin-ssr][Warning] Vite's development server was instantiated while the environment
is set to be a production environment by `process.env.NODE_ENV === 'production'` which is
contradictory.
[vite-plugin-ssr][Warning] Vite's development server wasn't instantiated while the environment
is set to be a development environment by `process.env.NODE_ENV === undefined` which is
contradictory.