@lazarv/react-server/node
Mount the runtime inside an existing Node.js HTTP server (Express, Fastify, NestJS, raw http). Used in middleware mode and custom server setups.
function reactServer(options?: ReactServerOptions, initialConfig?: Record<string, any>): Promise<{
middlewares: NodeMiddleware;
}>;
function reactServer(root?: string, options?: ReactServerOptions, initialConfig?: Record<string, any>): Promise<{
middlewares: NodeMiddleware;
}>;
Use @lazarv/react-server as a middleware in a Node.js server.
Parameters
options— Options for the server, same as the options for the react-server CLI commandinitialConfig— Initial configuration for the application
interface ReactServerOptions {
outDir?: string;
cors?: boolean;
origin?: string;
https?: boolean;
host?: string;
port?: number;
trustProxy?: boolean;
}
type NodeMiddleware = (req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (err?: any) => void) => any;