> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Streamlit apps

> Create data visualization tools, dashboards, and prototypes using Streamlit.

[Streamlit](https://streamlit.io) is integrated with Cognite Data Fusion (CDF) and you can use it to create data visualization tools, dashboards, or prototypes and make these available in the <span class="ui-element">Flows</span> workspace. Access to data is governed by the user running the app, and users can only see data they already have access to.

Use Python code and the Cognite SDK to create your app and let CDF handle authentication, infrastructure, and data storage. In CDF, you'll also find tools for debugging and testing, and you can install public dependencies directly.

<Warning>
  The features described in this section are in [public preview](/cdf/product_feature_status#public-preview) and may change.
</Warning>

## Before you start

To develop Streamlit apps in CDF, we recommend that you get familiar with Python programming, the [Streamlit library](https://docs.streamlit.io), and the [Cognite Python SDK](/dev/sdks/python). Also, make sure that you have the necessary [access capabilities](/cdf/access/guides/capabilities#streamlit-apps).

## Create an app

<Steps>
  <Step title="Navigate to Streamlit apps">
    Navigate to <span class="ui-element">Data fusion</span> > <span class="ui-element">Build solutions</span> > <span class="ui-element">Streamlit apps</span>.
  </Step>

  <Step title="Create a new app">
    Select <span class="ui-element">Create app</span> and start from scratch, import a Streamlit application file, or use one of the CDF app templates.
  </Step>

  <Step title="Provide app details">
    Provide a title and description for your application.
  </Step>

  <Step title="Optional. Set access restrictions">
    Provide a data set to [restrict access](#manage-access) to your application.
  </Step>

  <Step title="Start developing the application">
    Learn more in the [CDF developer documentation](/dev) and the [Streamlit documentation](https://docs.streamlit.io/develop).
  </Step>
</Steps>

## Manage files

Split your project into multiple files and pages in the code editor. Import files and pages with the Python `import` statement.

To add additional files:

<Steps>
  <Step title="Add a new file">
    Select <span class="ui-element">+ Add file</span> from the side panel.
  </Step>

  <Step title="Select the file type">
    Library files are imported through Python code. Page files display as separate pages in the side panel when you run the application.
  </Step>
</Steps>

The file name determines the page order. To control the page order, you can prefix the names with a number. You can also use emojis to add icons, and use underscores to insert a whitespace in the name.

### Install third-party packages

From the <span class="ui-element">Settings</span> menu, you can install third-party packages from [PyPi](https://pypi.org) and specify versions using pip requirement specifiers. See also [limitations to packages](#technical-limitations).

### Manage access

Streamlit applications are stored using the [Cognite Files API](/api-reference/concepts/20230101/files). To access the applications you need access to the underlying files.

We recommend that you create dedicated data sets and use them to scope the access to the Streamlit applications, typically with `files:read` access for end users. App maintainers also need `files:write` access to the data sets.

See also [capabilities for Streamlit apps](/cdf/access/guides/capabilities#streamlit-apps).

## Publish applications

Published applications are available under <span class="ui-element">Custom apps</span> in the <span class="ui-element">Flows</span> workspace.

## Technical limitations

In CDF, Streamlit has these limitations:

* Streamlit requires access to CDNs for Python packages. Organizations with firewalls that block specific traffic, may need to [allow access to specific domains](/cdf/admin/allowlist).

* Streamlit is based on WebAssembly. By default, WebAssembly is enabled in modern browsers, but some organizations may have disabled it on their computers.

* CDF only supports **packages** written in pure Python. The error `Can't find a pure Python 3 wheel for ’\<package\>’` indicates that a package relies on native libraries incompatible with [Pyodide](https://pyodide.org). For more details and workarounds, refer to the Pyodide documentation.

* The browser environment limits **network access** due to cross-origin resource sharing (CORS) policies. This can affect access to external data sources and services.

  <Tip>
    CORS workarounds:

    * **Data ingestion via Cognite Function:** You can ingest data into CDF using a Cognite Function, allowing access within Streamlit once the data is available in CDF.
    * **Triggering HTTP actions with Cognite Functions:** If you need to perform an action via an HTTP request, you can trigger it using a Cognite Function directly from Streamlit. Note that some processing delay may occur as the function executes.
  </Tip>

* **Hardware resources** can limit browser-based environments. This includes access to graphics processing units (GPUs) and constraints on available memory and processing power.

* **Multithreading** isn't supported. Other functions, for example `sleep()`, may not perform as expected under Pyodide.

See also [Stlite limitations](https://github.com/whitphx/stlite?tab=readme-ov-file#limitations) and [Pyodide FAQ](https://pyodide.org/en/stable/usage/faq.html).
