@angular/platform-server
- Version 16.2.6
- Published
- 2.25 MB
- 2 dependencies
- MIT license
Install
npm i @angular/platform-server
yarn add @angular/platform-server
pnpm add @angular/platform-server
Overview
Angular - library for using Angular in Node.js
Index
Variables
Functions
Classes
Interfaces
Variables
variable BEFORE_APP_SERIALIZED
const BEFORE_APP_SERIALIZED: InjectionToken<(() => void | Promise<void>)[]>;
A function that will be executed when calling
renderApplication
orrenderModule
just before current platform state is rendered to string.
variable INITIAL_CONFIG
const INITIAL_CONFIG: InjectionToken<PlatformConfig>;
The DI token for setting the initial config for the platform.
variable ɵINTERNAL_SERVER_PLATFORM_PROVIDERS
const ɵINTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[];
variable ɵSERVER_CONTEXT
const ɵSERVER_CONTEXT: InjectionToken<string>;
An internal token that allows providing extra information about the server context (e.g. whether SSR or SSG was used). The value is a string and characters other than [a-zA-Z0-9-] are removed. See the default value in
DEFAULT_SERVER_CONTEXT
const.
variable ɵSERVER_RENDER_PROVIDERS
const ɵSERVER_RENDER_PROVIDERS: Provider[];
variable VERSION
const VERSION: Version;
Functions
function ɵsetDomTypes
ɵsetDomTypes: () => void;
function platformDynamicServer
platformDynamicServer: ( extraProviders?: StaticProvider[] | undefined) => PlatformRef;
The server platform that supports the runtime compiler.
See Also
Deprecated
add an
import @angular/compiler
and replace the usage withplatformServer
instead.
function platformServer
platformServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
function provideServerRendering
provideServerRendering: () => EnvironmentProviders;
Sets up providers necessary to enable server rendering functionality for the application.
Basic example of how you can add server support to your application:
bootstrapApplication(AppComponent, {providers: [provideServerRendering()]});Returns
A set of providers to setup the server.
function renderApplication
renderApplication: <T>( bootstrap: () => Promise<ApplicationRef>, options: { document?: string | Document; url?: string; platformProviders?: Provider[]; }) => Promise<string>;
Bootstraps an instance of an Angular application and renders it to a string.
const bootstrap = () => bootstrapApplication(RootComponent, appConfig);const output: string = await renderApplication(bootstrap);Parameter bootstrap
A method that when invoked returns a promise that returns an
ApplicationRef
instance once resolved.Parameter options
Additional configuration for the render operation: -
document
- the document of the page to render, either as an HTML string or as a reference to thedocument
instance. -url
- the URL for the current render request. -platformProviders
- the platform level providers for the current render request.Returns
A Promise, that returns serialized (to a string) rendered page, once resolved.
function renderModule
renderModule: <T>( moduleType: Type<T>, options: { document?: string | Document; url?: string; extraProviders?: StaticProvider[]; }) => Promise<string>;
Bootstraps an application using provided NgModule and serializes the page content to string.
Parameter moduleType
A reference to an NgModule that should be used for bootstrap.
Parameter options
Additional configuration for the render operation: -
document
- the document of the page to render, either as an HTML string or as a reference to thedocument
instance. -url
- the URL for the current render request. -extraProviders
- set of platform level providers for the current render request.
Classes
class PlatformState
class PlatformState {}
Representation of the current platform state.
constructor
constructor(_doc: any);
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<PlatformState, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<PlatformState>;
method getDocument
getDocument: () => any;
Returns the current DOM state.
method renderToString
renderToString: () => string;
Renders the current state of the platform to string.
class ServerModule
class ServerModule {}
The ng module for the server.
class ServerTransferStateModule
class ServerTransferStateModule {}
NgModule to install on the server side while using the
TransferState
to transfer state from server to client.Note: this module is not needed if the
renderApplication
function is used. TherenderApplication
makes all providers from this module available in the application.Deprecated
no longer needed, you can inject the
TransferState
in an app without providing this module.
Interfaces
interface PlatformConfig
interface PlatformConfig {}
Config object passed to initialize the platform.
property baseUrl
baseUrl?: string;
Note: this option has no effect and can be removed from the config.
The base URL for resolving absolute URL for HTTP requests. It must be set if
useAbsoluteUrl
is true, and must consist of protocol, hostname, and optional port. This option has no effect ifuseAbsoluteUrl
is not enabled.Deprecated
This option is a noop.
property document
document?: string;
The initial DOM to use to bootstrap the server application. create a new DOM using Domino
property url
url?: string;
The URL for the current application state. This is used for initializing the platform's location.
protocol
,hostname
, andport
will be overridden ifbaseUrl
is set. none
property useAbsoluteUrl
useAbsoluteUrl?: boolean;
Note: this option has no effect and can be removed from the config.
Whether to append the absolute URL to any relative HTTP requests. If set to true, this logic executes prior to any HTTP interceptors that may run later on in the request.
baseUrl
must be supplied if this flag is enabled.Deprecated
This option is a noop. false
Package Files (1)
Dependencies (2)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (5)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@angular/platform-server
.
- Markdown[](https://www.jsdocs.io/package/@angular/platform-server)
- HTML<a href="https://www.jsdocs.io/package/@angular/platform-server"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3549 ms. - Missing or incorrect documentation? Open an issue for this package.