Reference
Asset and translation services, directives, pipes, image optimization, and the full API reference for the Angular SDK for Localess.
Asset Service
LocalessAssetService generates asset URLs. Its API is identical whether called server-side or in the browser.
import { LocalessAssetService } from '@localess/angular';
@Injectable()
export class MyService {
private assetService = inject(LocalessAssetService);
getUrl(asset: ContentAsset): string {
return this.assetService.link(asset);
// or: this.assetService.link('path/to/asset.jpg')
}
}SchemaComponent.assetUrl() and the llAsset pipe use the same underlying logic (LocalessClientService.assetLink()) — all three are equivalent.
Requesting a transformed asset (resize / format conversion)
Pass an AssetTransformParams object as the second argument to request a resized image or a different output format:
assetService.link(asset, { w: 400, f: 'webp' });
assetService.link(asset, { w: 800, h: 600, q: 70, f: 'avif' });| Param | Type | Description |
|---|---|---|
w | number | Target width in pixels |
h | number | Target height in pixels (combined with w, crops to cover the box) |
q | number | Output quality 1–100 (default 85; ignored for PNG) |
f | 'webp' | 'jpeg' | 'png' | 'avif' | Converts the output format |
download | boolean | Forces a browser download via Content-Disposition |
thumbnail | boolean | Extracts the first frame of an animated/video asset before resizing |
Translation Service
LocalessTranslationService fetches translation strings for a given locale.
import { LocalessTranslationService } from '@localess/angular';
@Injectable()
export class MyService {
private translationService = inject(LocalessTranslationService);
async getTranslations(locale: string) {
return this.translationService.fetch(locale);
}
}The returned Translations object is a flat key–value map (Record<string, string>).
Directives
Use these when you have a component or element that is not rendered through [llComponent]/<ll-document> but should still be selectable in the Visual Editor.
[data-ll-id] and [data-ll-schema]
Marker directives. Apply both together to any element to make it recognizable in the Visual Editor:
<div [attr.data-ll-id]="item._id" [attr.data-ll-schema]="item._schema">
<!-- content -->
</div>[data-ll-field]
Marks an individual field within a schema for field-level selection in the Visual Editor:
<p data-ll-field="subtitle">{{ data.subtitle }}</p>[llContent]
A convenience directive that sets both data-ll-id and data-ll-schema on the host element from a single ContentDataSchema input binding. Useful for sub-schemas rendered without going through the component registry:
import { ContentDirective } from '@localess/angular';
@Component({
imports: [ContentDirective],
})
export class PageComponent {}<div [llContent]="subSchema">
<!-- sub-schema content -->
</div>Pipes
Import individual pipes into the imports array of any standalone component that uses them.
llAsset — Asset URL
Transforms a ContentAsset object into a fully qualified CDN URL. Equivalent to assetUrl() on schema components.
import { AssetPipe } from '@localess/angular';
@Component({ imports: [AssetPipe] })<img [src]="data.image | llAsset" alt="..." />
<img [src]="data.image | llAsset:{ w: 400, f: 'webp' }" alt="..." />See Requesting a transformed asset above for the full AssetTransformParams field reference.
llLink — Link Resolution
Resolves a ContentLink from the links map to a navigable path or URL. Pass the links map as the piped value and the ContentLink as the argument:
import { LinkPipe } from '@localess/angular';<a [href]="links | llLink: data.ctaLink">Visit</a>ContentLink.type | Result |
|---|---|
"content" | Looks up link.uri in the links map and returns /<fullSlug> |
"url" | Returns link.uri as-is |
llRichText — Rich Text
Converts a Localess RichText field (Tiptap JSON) to sanitizer-trusted SafeHtml, synchronously. Bind it straight to [innerHTML] — no | async and no | llSafeHtml in the chain:
import { LocalessRichTextPipe } from '@localess/angular';
@Component({ imports: [LocalessRichTextPipe] })<div [innerHTML]="data.body | llRichText"></div>The pipe accepts LocalessRichTextInput — a full document, a single node, an array of nodes, or null/undefined — so a field value passes through without casting, and an unfilled field renders nothing. Supports headings (H1–H6), bold, italic, strike, underline, code, bullet lists, ordered lists, code blocks, and links. Pass a renderer override map as the pipe argument (data.body | llRichText: myRenderers) to replace the output for one element.
The HTML is generated and escaped by @localess/richtext rather than taken from raw input, which is what makes the pipe's internal bypassSecurityTrustHtml safe.
<ll-rich-text> — Rich Text component
The component form of the same renderer, for when a host element is more convenient than a pipe binding:
import { LocalessRichText } from '@localess/angular';
@Component({ imports: [LocalessRichText] })<ll-rich-text [content]="data.body" />| Input | Type | Description |
|---|---|---|
content | LocalessRichTextInput | Required. The rich text field value |
renderers | LocalessRichTextRenderers<string> | Optional per-node/per-mark overrides, keyed by element name |
llSafeHtml — Safe HTML
Bypasses Angular's DomSanitizer for a trusted HTML string. Accepts string | null | undefined, with the latter two treated as empty HTML.
You don't need this for rich text — llRichText and <ll-rich-text> already return trusted SafeHtml. Reach for llSafeHtml only for HTML from some other trusted source in your space.
<div [innerHTML]="data.embedHtml | llSafeHtml"></div>Security:
llSafeHtmlcallsDomSanitizer.bypassSecurityTrustHtml(). Only use it with HTML that comes directly from your trusted Localess space.
Angular Image Optimization
provideLocaless() automatically registers Angular's IMAGE_LOADER provider. When you use NgOptimizedImage (ngSrc) with a Localess asset URL, Angular appends ?w=<requested-width> to the URL for server-side image resizing:
<img
ngSrc="{{ data.image | llAsset }}"
width="800"
height="600"
alt="Hero image"
/>
<!-- Rendered src: https://my-localess.web.app/api/v1/spaces/.../assets/image.jpg?w=800 -->No additional configuration is required.
API Reference
@localess/angular
| Export | Kind | Description |
|---|---|---|
provideLocaless(options, ...features) | Function | Registers all providers, given the config options |
withLocalessComponents(components, fallback?) | Function | Registers the _schema → component registry used by [llComponent] / <ll-document> |
LocalessDocument | Component | <ll-document> — renders a full Content response with live sync |
LocalessRichText | Component | <ll-rich-text> — renders a rich text field into the host element |
SchemaComponent<T> | Abstract Class | Base component with data, links, references, assets signal inputs |
LocalessComponentDirective | Directive | [llComponent] — dynamically renders the registered component for a _schema key |
ContentIdDirective | Directive | [data-ll-id] marker |
ContentSchemaDirective | Directive | [data-ll-schema] marker |
ContentFieldDirective | Directive | [data-ll-field] marker |
ContentDirective | Directive | [llContent] — sets both id and schema attributes |
AssetPipe | Pipe | llAsset — asset to URL, with optional transform params |
LinkPipe | Pipe | llLink — resolves a ContentLink |
LocalessRichTextPipe | Pipe | llRichText — Tiptap JSON to trusted SafeHtml, synchronously |
SafeHtmlPipe | Pipe | llSafeHtml — bypasses DomSanitizer |
LocalessClientService | Service | Low-level wrapper around @localess/client, used internally by the other services |
LocalessContentService | Service | Fetches content by slug, ID, or links, with TransferState hydration |
LocalessAssetService | Service | Programmatic asset URL generation |
LocalessTranslationService | Service | Fetches translations by locale |
LocalessSyncService | Service | Visual Editor sync — on() / onChange() / enabled() / ready() |
LocalessComponentResolver | Service | Resolves _schema keys to components via the registry; used internally by [llComponent] |
buildAssetQueryString(params?) | Function | Standalone asset transform query-string builder |
findLink(links, link) | Function | Standalone link resolution utility |
LocalessApiError | Class | Thrown when the API responds with a non-2xx status code |
Also re-exports all types from @localess/client:
| Type | Description |
|---|---|
Content<T> | CMS document with metadata and typed data payload |
ContentData | Base type for schema data objects |
ContentDataSchema | Schema data with _id and _schema fields |
ContentAsset | Asset reference { uri: string } |
ContentLink | Link reference { type: 'content' | 'url', uri: string } |
ContentRichText | Tiptap JSON rich text |
Links | Map of content ID → { fullSlug: string } |
References | Map of referenced content objects |
Assets | Map of asset ID → asset metadata |
Translations | Flat key–value map of translation strings |
ContentFetchParams | Parameters for content fetch requests |
LinksFetchParams | Parameters for links fetch requests |
AssetTransformParams | Asset transform parameters (w, h, f, q, thumbnail, download) |
LocalessSync | Visual Editor sync event types |
EventToApp / EventToAppOf / EventCallback / EventToAppType | Visual Editor sync event payload types |
LocalessComponentsMap / LocalessComponentLoader | Types for the withLocalessComponents() registry |
Visual Editor
Subscribe to Localess Visual Editor live-editing events with the Angular SDK for Localess.
Getting Started
Astro SDK for Localess — dynamic component rendering by content schema, rich text rendering, asset management, and Visual Editor integration for static and server-rendered Astro projects.