new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vite · Guide · all subjects

environment api/ssr

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

SSR middleware example with environment API

Example SSR middleware setup using the Environment API in middleware mode: Create a Vite server with appType 'custom' and middlewareMode true. Define a server environment in the environments config. Access serverEnvironment.runner.import('/src/entry-server.js') to load the server entry. Call viteServer.transformIndexHtml(url, template) to apply Vite HTML transforms that inject the Vite HMR client. Render the app HTML with the imported render function, then inject the result into the template before sending the response.

createServerHotChannel for SSR environments

For an SSR environment running in the same Node.js process as the Vite server, Vite exports createServerHotChannel as a ready-made HotChannel that can be passed to new DevEnvironment(name, config, { hot: true, transport: createServerHotChannel() }).

SSR app has two environments

In a typical server-side rendered app, there are two environments: client (runs the app in the browser) and ssr (runs the app in node or other server runtimes to render pages before sending to the browser).

ssr property deprecation planned

The ssr top-level property is going to be deprecated once the Environment API is stable. This option has the same role as environments but only allowed configuring a small set of options.

Give your agent this brain