> Markdown version of [Creating New Views](https://vaadin.com/docs/v14/flow/starters/business-app/creating-new-views). Section index: [llms.txt](https://vaadin.com/docs/v14/flow/llms.txt)

# Creating New Views

The bare minimum needed when creating a new view is to define the `Route`, and to extend `Component` directly (**example 1**) or indirectly (**example 2**).

You can also extend `ViewFrame` to build a view with a header, scrollable content and footer (**example 3**). Most of the Business App Starter views are built with `ViewFrame`. They are located in the `com.vaadin.starter.business.ui.views` package.

## <a id="example-1-extending-component"></a>Example 1: Extending Component

If you extend `Component` directly, you must annotate the class with `@Tag`, e.g. `@Tag("div")`. For more information on how to use `Component` as a container, please see the [Creating a Component Container](https://vaadin.com/docs/v14/flow/creating-components/tutorial-component-container).

```java
@Route(value = <URL_fragment>, layout = MainLayout.class)
@Tag("div")
public class MyView extends Component {
  public MyView() {
    // Content goes here.
    getElement().appendChild(...);
  }
}
```

## <a id="example-2-extending-div"></a>Example 2: Extending Div

```java
@Route(value = <URL_fragment>, layout = MainLayout.class)
public class MyView extends Div {
  public MyView() {
    // Content goes here.
    add(...);
  }
}
```

## <a id="example-3-extending-viewframe"></a>Example 3: Extending ViewFrame

`setViewHeader`, `setViewContent` and `setViewFooter` all take a set of components, and puts them in their respective slot. All slots are optional.

```java
@Route(value = <URL_fragment>, layout = MainLayout.class)
public class MyView extends ViewFrame {
  public MyView() {
    setViewHeader(Component... components);
    setViewContent(Component... components);
    setViewFooter(Component... components);
  }
}
```

For more info see the [Get started](https://vaadin.com/docs/v14/flow/guide) section.

## <a id="please-remember"></a>Please Remember

A few things to keep in mind when creating a new view:

- The URL fragment must be unique.

- The layout parameter defines the parent. Views are rendered inside their parent layout.

**The Business App Starter is built around `MainLayout.class`. Please use it as the default parent layout when creating new views.**

For information regarding routing in Vaadin, please see [Routing and Navigation](https://vaadin.com/docs/v14/flow/routing).

## <a id="adding-a-view-to-the-sidebar"></a>Adding a View to the Sidebar

Once you’ve created your view, it’s time to add it to the `NaviDrawer` so that it can be accessed via the UI. Open up `MainLayout.java`, and go to the `initNaviItems` method.

This is where the navigation items are set up and added to the `NaviDrawer`. A navigation item consists of an icon, a title and a navigation target.

To add the view we created in the previous step, add the following line:

```java
private void initNaviItems() {
  ...
  naviDrawer.addNaviItem(VaadinIcon.<ICON>, "My View", MyView.class);
  ...
}
```

`24E9B57C-FF92-43DC-923A-971968CDFB89`
