Overview
The@angular/platform-browser package provides the infrastructure for running Angular applications in a web browser. It includes bootstrapping APIs, DOM manipulation services, and security utilities for browser-based applications.
Bootstrap Functions
bootstrapApplication
Bootstraps a standalone component as the root of an Angular application.Type<unknown>
required
A standalone component to render as the application root.
ApplicationConfig
Configuration object containing providers and other application settings.
BootstrapContext
Optional context providing a pre-existing platform injector (useful for server-side rendering).
Promise<ApplicationRef> - The bootstrapped application reference.
Example:
The root component must be a standalone component. Use
standalone: true in the component decorator.createApplication
Creates an Angular application without bootstrapping any components. Components can be bootstrapped later using the returnedApplicationRef.
ApplicationConfig
Configuration object containing providers and other application settings.
BootstrapContext
Optional context providing a pre-existing platform injector.
Promise<ApplicationRef> - Application reference for manual component bootstrapping.
Example:
platformBrowser
Creates a browser platform instance. This is typically used for advanced scenarios where you need explicit control over platform creation.StaticProvider[]
Optional additional platform-level providers.
PlatformRef - Browser platform reference.
Example:
Modules
BrowserModule
Exports required infrastructure for all Angular apps running in a browser. IncludesCommonModule and ApplicationModule.
Services
Title
Service for getting and setting the HTML document title.() => string
Returns the current document title.
(newTitle: string) => void
Sets the document title.
Meta
Service for managing HTML<meta> tags. Essential for SEO, social sharing, and security configurations.
(tag: MetaDefinition, forceCreation?: boolean) => HTMLMetaElement | null
Adds a meta tag to the document. If
forceCreation is false (default), returns existing tag if found.(tags: MetaDefinition[], forceCreation?: boolean) => HTMLMetaElement[]
Adds multiple meta tags to the document.
(attrSelector: string) => HTMLMetaElement | null
Retrieves a meta tag using an attribute selector (e.g.,
"name='description'").(attrSelector: string) => HTMLMetaElement[]
Retrieves all meta tags matching the attribute selector.
(tag: MetaDefinition, selector?: string) => HTMLMetaElement | null
Updates an existing meta tag or creates one if it doesn’t exist.
(attrSelector: string) => void
Removes a meta tag matching the attribute selector.
DomSanitizer
Service for sanitizing values to prevent Cross-Site Scripting (XSS) attacks. Provides methods to sanitize or bypass sanitization for trusted content.SecurityContext.HTML- HTML contentSecurityContext.STYLE- CSS stylesSecurityContext.SCRIPT- JavaScript codeSecurityContext.URL- URLs in hyperlinks or imagesSecurityContext.RESOURCE_URL- URLs for loading executable code
(context: SecurityContext, value: SafeValue | string | null) => string | null
Sanitizes a value for use in the specified security context.
(value: string) => SafeHtml
Marks HTML as trusted. WARNING: Only use with trusted content to avoid XSS vulnerabilities.
(value: string) => SafeStyle
Marks CSS as trusted. WARNING: Only use with trusted content.
(value: string) => SafeScript
Marks JavaScript as trusted. WARNING: Only use with trusted content.
(value: string) => SafeUrl
Marks a URL as trusted. WARNING: Only use with trusted URLs.
(value: string) => SafeResourceUrl
Marks a resource URL as trusted. WARNING: Only use with trusted resource URLs.
Hydration
provideClientHydration
Configures client-side hydration for applications using server-side rendering (SSR). Hydration improves initial load performance by reusing server-rendered DOM.HydrationFeature[]
Optional hydration features to enable (event replay, i18n support, etc.).
withEventReplay()- Replays user events that occurred before hydration completedwithI18nSupport()- Enables hydration for internationalized contentwithNoHttpTransferCache()- Disables HTTP response caching between server and clientwithHttpTransferCacheOptions(options)- Configures HTTP transfer cachewithIncrementalHydration()- Enables incremental hydration for better performance
Client-side hydration requires server-side rendering to be configured. See
@angular/platform-server for SSR setup.Utilities
provideProtractorTestingSupport
Provides testability support for applications using Protractor or other testing tools that rely on Angular’s testability APIs.By
Utility class for creating platform-agnostic DOM selectors in tests.Related APIs
@angular/platform-server
Server-side rendering APIs
@angular/core
Core Angular APIs
Router
Application routing
HttpClient
HTTP communication
