[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/platform-server/renderApplication [Back]  [Original]

renderApplication Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/platform-server

renderApplication

function
stable

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

On this page

    arrow_upward_alt Back to the top

    API

    function renderApplication(
      bootstrap: (context: BootstrapContext) => Promise<ApplicationRef>,
      options: {
        document?: string | Document | undefined;
        url?: string | undefined;
        platformProviders?: Provider[] | undefined;
        allowedHosts?: string[] | undefined;
      },
    ): Promise<string>;
    @parambootstrap(context: BootstrapContext) => Promise<ApplicationRef>

    A method that when invoked returns a promise that returns an ApplicationRef instance once resolved. The method is invoked with an Injector instance that provides access to the platform-level dependency injection context.

    @paramoptions{ document?: string | Document | undefined; url?: string | undefined; platformProviders?: Provider[] | undefined; allowedHosts?: string[] | undefined; }

    Additional configuration for the render operation:

    • 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.
    • platformProviders - the platform level providers for the current render request.
    • allowedHosts - the allowed hosts list for host validation in server-side rendering.
    @returnsPromise<string>

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

    Usage Notes

    import { BootstrapContext, bootstrapApplication } from '@angular/platform-browser';
    import { renderApplication } from '@angular/platform-server';
    import { ApplicationConfig } from '@angular/core';
    import { AppComponent } from './app.component';
    
    const appConfig: ApplicationConfig = { providers: [...] };
    const bootstrap = (context: BootstrapContext) =>
      bootstrapApplication(AppComponent, config, context);
    const output = await renderApplication(bootstrap);
    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page