# Pre-Loading Data in Mobile Apps

If your app’s main interface is not the MapsIndoors map — such as a welcome screen with an overview of features as on the screenshot below — you can improve performance by loading MapsIndoors data separately from displaying the map.

This approach, available in mobile SDKs for Android, iOS, Flutter, and React Native, ensures users can interact with the map instantly without waiting for data to load.

<figure><img src="https://3753991427-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5JnPt1idRurEBSNUY3SR%2Fuploads%2Fl2kVlsj1ltT6mI7hyrdM%2Fload-data.png?alt=media&#x26;token=cdc86890-12ed-465c-bc80-a9118352617a" alt=""><figcaption></figcaption></figure>

## How to Pre-Load MapsIndoors Data

You don’t need to change how you initialise MapsIndoors, but you should decouple loading the data from showing the map. Instead of loading data only when the user requests the map, load it as early as possible.

In this approach, data loading only begins when the user requests the map, causing delays.

{% hint style="warning" %}
**Not recommended:** Loading Data on Demand
{% endhint %}

```swift
// MyController.swift

func showMapOnUserRequest() {
    try await MPMapsIndoors.shared.load(apiKey: "mapspeople3d")
    // Create MPMapConfig instance
    // Create MPMapControl instance
    // Show and use the map
}
```

Instead, start loading MapsIndoors data as soon as the app launches. Then, when the user requests the map, it will be ready to display instantly.

{% hint style="success" %}
**Recommended approach:** Pre-loading Data in Advance
{% endhint %}

```swift
// AppDelegate.swift

func loadMapsIndoorsData() {
    try await MPMapsIndoors.shared.load(apiKey: "mapspeople3d")
}
```

When the user requests the map, you can display it immediately with the pre-loaded data:

```swift
// MyMapController.swift

func showMapOnUserRequest() {
    // Create MPMapConfig instance
    // Create MPMapControl instance
    // Show and use the map
}
```

By pre-loading data, you ensure a smooth and responsive experience for your users, making your MapsIndoors-powered app feel faster and more seamless.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mapsindoors.com/academy/boost-performance/pre-loading-data-in-mobile-apps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
