function developer preview

Bootstraps an instance of an Angular application and renders it to a string.

See more...

renderApplication<T>(rootComponent: Type<T>, options: { appId: string; document?: string | Document; url?: string; providers?: (Provider | ImportedNgModuleProviders)[]; platformProviders?: Provider[]; }): Promise<string>

rootComponent Type<T>

A reference to a Standalone Component that should be rendered.

options object

Additional configuration for the render operation:

  • appId - a string identifier of this application. The appId is used to prefix all server-generated stylings and state keys of the application in TransferState use-cases.
  • document - the document of the page to render, either as an HTML string or as a reference to the document instance.
  • url - the URL for the current render request.
  • providers - set of application level providers for the current render request.
  • platformProviders - the platform level providers for the current render request.

Promise<string>: A Promise, that returns serialized (to a string) rendered page, once resolved.


Note: the root component passed into this function must be a standalone one (should have the standalone: true flag in the @Component decorator config).

  standalone: true,
  template: 'Hello world!'
class RootComponent {}

const output: string = await renderApplication(RootComponent, {appId: 'server-app'});

© 2010–2022 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.