# UI Hosting

> A guide exploring different UI hosting strategies and their benefits when using Backend For Frontend (BFF) systems

When building modern web applications, selecting the right hosting strategy for your UI assets is crucial for optimizing performance, simplifying deployment, and ensuring seamless integration with Backend For Frontend (BFF) systems. This guide explores various hosting approaches and their benefits.

## Hosting Options for the UI

[Section titled âHosting Options for the UIâ](#hosting-options-for-the-ui)

There are several options for hosting the UI assets when using a BFF.

* Host the assets within the BFF host using the static file middleware
* Host the UI and BFF separately on subdomains of the same site and use CORS to allow cross-origin requests
* Serves the index page of the UI from the BFF host, and all other assets are loaded from another domain, such as a CDN

### Serving SPA assets from BFF host

[Section titled âServing SPA assets from BFF hostâ](#serving-spa-assets-from-bff-host)

Hosting the UI together with the BFF is the simplest choice, as requests from the front end to the backend will automatically include the authentication cookie and not require CORS headers. This makes the BFF and the front-end application a single deployable unit. Below shows a graphical overview of what that would look like:

![Hosting BFF UI from the UI](/_astro/bff_ui_hosting_loc.Cidk5i8u_ZBS8tg.svg)

If you create a BFF host using our templates, the UI will be hosted in this way:

Terminal

```bash
dotnet new duende-bff-remoteapi