Bootstrap
Start an Angular app on Lynx and register the renderer that draws it. import { bootstrapApplication, provideRenderer, loadLazyBundle } from '@blotch/angular-lynx';
Usage
ng add @blotch/angular-lynx writes both files for you.
API
bootstrapApplication()
Starts your app on Lynx. Use it instead of the bootstrapApplication from @angular/platform-browser, which needs a browser DOM.
- Runs twice. Your bundle starts the app on both the main thread and the background thread. See Threads.
- Waits for Lynx. On the main thread, it waits until Lynx is ready to render the page.
- Hot reload. Calling it again destroys the running app first, then starts the new one.
- Returns the
ApplicationRef, as Angular's version does.
provideRenderer()
Registers the renderer that turns your templates into Lynx elements. Every app needs it, together with provideZonelessChangeDetection().
It also provides these Angular tokens:
loadLazyBundle()
Loads a component from a separately built Lynx bundle at runtime.
- Resolves with the bundle's default export, or with all its exports when it has no default.
- Caches by
source: repeat calls return the same promise. - On the background thread, it rejects when the bundle fails to load or run.
- On the main thread, it loads synchronously. If loading fails, the promise never settles and the component doesn't appear.
- Rejects when Lynx's bundle loader isn't available, such as in unit tests.
Lazy routes with import() and @defer blocks don't need loadLazyBundle(). The build includes their code for you. These docs don't yet cover how to build a standalone component bundle.
Types
This page uses only Angular types: ApplicationConfig, ApplicationRef, EnvironmentProviders and Type from @angular/core.
Related
- Quick Start: create an app that already has this setup.
- How a Lynx app runs
- Signals and change detection: why the app must be zoneless.
- Routing: add
provideRouter()next toprovideRenderer(). - Errors and logging
