Close Docs

Frame (<disco-frame>)

The root container for the application. It manages navigation history, caching, and transitions between pages.

Usage

<disco-frame id="myFrame"></disco-frame>

API

navigate(page: HTMLElement): Promise<void>

Navigates to an existing DOM element (must be a DiscoPage or derivative).

const page = document.getElementById('detailsPage');
await frame.navigate(page);

loadPage(path: string, options?): Promise<HTMLElement>

Fetches an external HTML file, parses it, and appends it to the frame in a hidden state. This is useful for lazy loading views.

Options:

Note: Scripts inside the loaded HTML file are NOT executed for security and performance reasons.

const profilePage = await frame.loadPage('views/profile.html', {
    onLoad: (page) => {
        page.querySelector('.save-btn').onclick = saveProfile;
    }
});
await frame.navigate(profilePage);

goBack(): Promise<void>

Navigates back one step in the history. Use window.history.back() integration if enabled.

await frame.goBack();

Attributes

Safe Area Insets

<disco-frame> respects the disco-inset-top and disco-inset-bottom values defined on the root and adds padding so page content stays inside the safe area.