Localess
Angular

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' });
ParamTypeDescription
wnumberTarget width in pixels
hnumberTarget height in pixels (combined with w, crops to cover the box)
qnumberOutput quality 1–100 (default 85; ignored for PNG)
f'webp' | 'jpeg' | 'png' | 'avif'Converts the output format
downloadbooleanForces a browser download via Content-Disposition
thumbnailbooleanExtracts 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.

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.typeResult
"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" />
InputTypeDescription
contentLocalessRichTextInputRequired. The rich text field value
renderersLocalessRichTextRenderers<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: llSafeHtml calls DomSanitizer.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

ExportKindDescription
provideLocaless(options, ...features)FunctionRegisters all providers, given the config options
withLocalessComponents(components, fallback?)FunctionRegisters the _schema → component registry used by [llComponent] / <ll-document>
LocalessDocumentComponent<ll-document> — renders a full Content response with live sync
LocalessRichTextComponent<ll-rich-text> — renders a rich text field into the host element
SchemaComponent<T>Abstract ClassBase component with data, links, references, assets signal inputs
LocalessComponentDirectiveDirective[llComponent] — dynamically renders the registered component for a _schema key
ContentIdDirectiveDirective[data-ll-id] marker
ContentSchemaDirectiveDirective[data-ll-schema] marker
ContentFieldDirectiveDirective[data-ll-field] marker
ContentDirectiveDirective[llContent] — sets both id and schema attributes
AssetPipePipellAsset — asset to URL, with optional transform params
LinkPipePipellLink — resolves a ContentLink
LocalessRichTextPipePipellRichText — Tiptap JSON to trusted SafeHtml, synchronously
SafeHtmlPipePipellSafeHtml — bypasses DomSanitizer
LocalessClientServiceServiceLow-level wrapper around @localess/client, used internally by the other services
LocalessContentServiceServiceFetches content by slug, ID, or links, with TransferState hydration
LocalessAssetServiceServiceProgrammatic asset URL generation
LocalessTranslationServiceServiceFetches translations by locale
LocalessSyncServiceServiceVisual Editor sync — on() / onChange() / enabled() / ready()
LocalessComponentResolverServiceResolves _schema keys to components via the registry; used internally by [llComponent]
buildAssetQueryString(params?)FunctionStandalone asset transform query-string builder
findLink(links, link)FunctionStandalone link resolution utility
LocalessApiErrorClassThrown when the API responds with a non-2xx status code

Also re-exports all types from @localess/client:

TypeDescription
Content<T>CMS document with metadata and typed data payload
ContentDataBase type for schema data objects
ContentDataSchemaSchema data with _id and _schema fields
ContentAssetAsset reference { uri: string }
ContentLinkLink reference { type: 'content' | 'url', uri: string }
ContentRichTextTiptap JSON rich text
LinksMap of content ID → { fullSlug: string }
ReferencesMap of referenced content objects
AssetsMap of asset ID → asset metadata
TranslationsFlat key–value map of translation strings
ContentFetchParamsParameters for content fetch requests
LinksFetchParamsParameters for links fetch requests
AssetTransformParamsAsset transform parameters (w, h, f, q, thumbnail, download)
LocalessSyncVisual Editor sync event types
EventToApp / EventToAppOf / EventCallback / EventToAppTypeVisual Editor sync event payload types
LocalessComponentsMap / LocalessComponentLoaderTypes for the withLocalessComponents() registry

On this page