---
# System prepended metadata

title: Render views
tags: [brew-js-react]

---

---
tags: brew-js-react
---

# Render views

Use `renderView` to specify a list of views to render.

The views are matched in the provided order, using the `isViewMatched` predicate. If there is no view matches current path, it will automicatically redirects the SPA to the proper path which renders the first view.

```typescript
import { renderView } from "brew-js-react";
import { Home, Foo } from "./views";

function App() {
    return renderView(Home, Foo);
}
```

## Restricting accessible views

It is possible to restrict which views can be accessed under certain state:

```typescript
import { renderView } from "brew-js-react";
import { Home, Login, ProductInfo, ProductEditor } from "./views";

function App() {
    const [role, setRole] = useState();
    switch (role) {
        case 'editor':
            return renderView(Home, ProductInfo, ProductEditor, Admin);
        case 'reader':
            return renderView(Home, ProductInfo);
        default:
            return renderView(Login);
    }
}
