Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Latest commit

 

History

History
31 lines (22 loc) · 1.35 KB

Using-SSR-with-Flex-Layout.md

File metadata and controls

31 lines (22 loc) · 1.35 KB

@angular/flex-layout now supports server-side rendering (SSR).

Developers should see the Universal Demo app source for details:

The app.server.module uses the FlexLayoutServerModule (instead of the FlexLayoutModule).

The FlexLayoutServerModule entrypoint consolidates the logic for running Flex Layout on the server. Because SSR usings uses Node.js APIs, the FlexLayoutServerModule must be segmented into a server-only bundle.

This also helps avoid including server code in the browser bundle.

The FlexLayoutServerModule, can be imported into a server modulefile, e.g. app.server.module.ts as follows:

import {NgModule} from '@angular/core';
import {FlexLayoutServerModule} from '@angular/flex-layout/server';

@NgModule(({
  imports: [
    ... other imports here
    FlexLayoutServerModule,
  ]
}))
export class AppServerModule {}

This module - in addition to handling all of the style processing/rendering before the Angular app is bootstrapped on the server - also substitutes the version of MatchMedia with a server-compatible implementation called ServerMatchMedia.