> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Embed in an existing native app

Already have an iOS or Android app? Show your Angular app as one or more screens inside it. You don't have to ship the app that `ng build --platform` generates.

:::info This page needs native code
Embedding means changing your iOS or Android project, in Swift, Objective-C, Kotlin or Java. It's the one place in these docs where you need native knowledge. Work through it with whoever maintains your native app.
:::

## How it fits together

Your native app adds the Lynx engine. It shows your bundle in a [**LynxView**](/guide/glossary.md#lynxview): a native view that runs a Lynx bundle, like an `<iframe>` for Lynx content. You place a LynxView in your own screens, as you would any other native view.

```mermaid
flowchart LR
    A["ng build"] --> B["main.lynx.bundle<br/>and static/"]
    B --> C["Your native app"]
    C -->|"your loader reads the bundle"| D["LynxView"]
    D --> E["Your Angular app on screen"]
```

Your native app becomes the [**host app**](/guide/glossary.md#host-app): the app that loads your bundle and shows it. Build the bundle with plain `ng build`, as in [Build your app](/guide/building-for-production.md).

## Add Lynx to your app

Lynx's guides cover the native setup:

- [Integrate with Existing Apps](https://lynxjs.org/guide/start/integrate-with-existing-apps) adds the Lynx engine to your project. Pick your platform from the tabs.
- [Embedding LynxView into Native View](https://lynxjs.org/guide/embed-lynx-to-native) sizes a LynxView inside your own screens.

The apps `ng build --platform` generates use Lynx 4.1.0, the version AngularLynx is tested with.

## What your app must do

Beyond Lynx's own setup, your app has three jobs:

1. [Load the bundle](#load-the-bundle)
2. [Serve `static/`](#serve-static)
3. [Link XElement](#link-xelement)

### Load the bundle

The Lynx engine doesn't fetch bundles itself. Your app gives it a **loader** that reads them, from the app or from the network:

- **iOS:** a `LynxTemplateProvider`
- **Android:** an `AbsTemplateProvider`

Lynx's integration guide shows one for each platform.

### Serve `static/`

Images and fonts your code imports load from `/static/...` paths. Pick one:

- **Ship `static/` inside your app,** and resolve `/static/...` paths against where you keep it. The generated apps do this.
- **Host it on a server,** and set RSpeedy's `output.assetPrefix` to its URL:

```typescript title="lynx.config.ts"
import { defineConfig } from '@blotch/angular-lynx-build';

export default defineConfig({
  output: { assetPrefix: 'https://cdn.example.com/my-app/' },
});
```

### Link XElement

:::warning Link XElement, or some elements render nothing
Some elements aren't part of Lynx's core. They come from Lynx's [**XElement**](/guide/glossary.md#xelement) library: `<input>`, `<textarea>`, `<overlay>`, `<svg>`, `<blur-view>`, `<viewpager>`, `<refresh>`, the `<scroll-coordinator>` family, `<webview>` and `<video>`.

An app that doesn't link XElement and register its elements renders nothing for these tags. On Android, the elements after them can disappear too. Nothing on screen says why.
:::

- **Android:** add `org.lynxsdk.lynx:xelement`, and call `addBehaviors(XElementBehaviors().create())` on the `LynxViewBuilder`.
- **iOS:** add the `XElement` pod.

Lynx's [integration guide](https://lynxjs.org/guide/start/integrate-with-existing-apps) has the details. The apps `ng build --platform` generates already do this, and so does Lynx Explorer.

## Bundled or downloaded

Your app can ship the bundle inside it, or download it from a server:

```mermaid
flowchart LR
    A[ng build] --> B["main.lynx.bundle"]
    B --> C{Delivery}
    C --> D[Inside the app]
    C --> E[On a server or CDN]
    D --> F[LynxView loads it]
    E --> F
```

| Strategy                                | Pros                                          | Cons                                        |
| --------------------------------------- | --------------------------------------------- | ------------------------------------------- |
| **Bundled:** ship it inside the app     | Loads instantly, works offline                | Changing the app needs a store update       |
| **Downloaded:** host it on a server/CDN | Update without a store release, run A/B tests | Needs the network, at least on first launch |

You can combine both. Ship a bundle with the app for an instant first launch, then check for a newer one in the background.

Before you serve updates this way:

- **Match the Lynx version.** A bundle only runs on a Lynx engine at least as new as its `targetSdkVersion`. That's an AngularLynx plugin option, which defaults to `3.2`. Every installed version of your app must be able to run what you serve. So raise `targetSdkVersion` only when every installed version's engine is that new.
- **Check the store rules.** Both stores have rules about code an app downloads after review. Read Apple's [App Review Guidelines](https://developer.apple.com/app-store/review/guidelines/) and Google Play's [Developer Program Policies](https://play.google.com/about/developer-content-policy/) before you rely on it.

## Copy the iOS extras

The iOS app `ng build --platform ios` generates adds two things XElement lacks. Copy them to get the same in your app.

### Glass that blurs and morphs

XElement's `<blur-view>` falls short of the [glass components](/dolan/glass.md):

- **Before iOS 26,** they draw UIKit's [blur materials](/dolan/glass.md#materials-before-ios-26), which XElement's `<blur-view>` doesn't have.
- **From iOS 26,** their glass [materializes, dissolves and morphs](/dolan/glass.md#morphing). XElement's sets at once.

The generated app adds both with a `<blur-view>` of its own, [`BlurView.swift`](https://github.com/Blotch-Smart-Frames/AngularLynx/blob/master/packages/native/templates/ios/App/BlurView.swift), and the [`GlassTransitions.swift`](https://github.com/Blotch-Smart-Frames/AngularLynx/blob/master/packages/native/templates/ios/App/GlassTransitions.swift) it uses. To get them:

1. Copy both files into your app.
2. Register `BlurView` for `blur-view`, in place of XElement's `LynxUIBlurView`.

Without them, the components draw Lynx's older blur instead, and their glass comes and goes at once.

### Web views that go away

On iOS, XElement's `<webview>` keeps its web view after the element goes. The WebContent process WebKit started for it stays too. So every `<webview>` your app shows stays for as long as the app runs, because its loader and its web view keep each other.

The generated app wraps XElement's loader so the web view goes with the element, in [`WebViewLoader.swift`](https://github.com/Blotch-Smart-Frames/AngularLynx/blob/master/packages/native/templates/ios/App/WebViewLoader.swift). To get it:

1. Copy the file into your app.
2. Call `ShellWebViewLoaderProvider.register()` before your first `LynxView`, where you register XElement's elements.

## Connect more native features

Some AngularLynx services call native code in the host app. The generated apps have all of it. In your own app, add what you use:

- [**Back button, memory and splash screen**](/guide/embedding/shell-module.md): the Android back button, freeing the memory closed screens hold, and hiding your loading view once Angular draws.
- [**Native features**](/guide/embedding/app-features.md): web sign-in, storage, links, shortcuts, the photo picker and the share sheet.
- [**Pass data from your native app**](/guide/embedding/host-data.md): send values into Angular, such as a signed-in user's ID or the app's theme.

## Related

- [Pass data from your native app](/guide/embedding/host-data.md)
- [Multi-page apps](/guide/multi-page.md): several bundles, each in its own LynxView.
- [Build your app](/guide/building-for-production.md)
- [Integrate with Existing Apps](https://lynxjs.org/guide/start/integrate-with-existing-apps) on lynxjs.org
