Skip to content

lit-ui-router-ssr / vite / serverRouterPlugin

Function: serverRouterPlugin() ​

ts
function serverRouterPlugin(router, options?): ServerRouterPlugin;

Defined in: packages/lit-ui-router-ssr/src/vite.ts:141

ui-router-server/vite's serverRouterPlugin, set up for a Lit app: with prerender, the worker loads the shim, then lit-ui-router-ssr/register, then any preload passed here, each once, before the prerender script, so the script imports everything statically. Its default export comes from this module's definePrerender.

vite dev and vite preview behave as under ui-router-server/vite.

Parameters ​

ParameterTypeDescription
routerServerRouterthe server router the middleware and the build step read
options?ServerRouterPluginOptionsthe Connect adapter's options, plus the build step

Returns ​

ServerRouterPlugin

a plugin to spread into plugins: [...]

Throws ​

from the build step when the script has no default export function, the built index.html is missing, or a listed path matches no route

Example ​

ts
import { createServerRouter } from 'ui-router-server';
import { serverRouterPlugin } from 'lit-ui-router-ssr/vite';

plugins: [
  serverRouterPlugin(createServerRouter({ mounts }), {
    prerender: './src/prerender.ts',
  }),
],