docs/getting-started/homepage--old.md
::::info This documentation is for Backstage apps that still use the old frontend system. If your app uses the new frontend system, read the current homepage guide instead. ::::
Having a good Backstage homepage can significantly improve the discoverability of the platform. You want your users to find all the things they need right from the homepage and never have to remember direct URLs in Backstage. The Home plugin introduces a system for composing a homepage for Backstage in order to surface relevant info and provide convenient shortcuts for common tasks. It's designed with composability in mind with an open ecosystem that allows anyone to contribute with any component, to be included in any homepage.
For App Integrators, the system is designed to be composable to give total freedom in designing a Homepage that suits the needs of the organization. From the perspective of a Component Developer who wishes to contribute with building blocks to be included in Homepages, there's a convenient interface for bundling the different parts and exporting them with both error boundary and lazy loading handled under the surface.
At the end of this tutorial, you can expect:
Before we begin, make sure
@backstage/create-app and not
using a fork of the backstage
repository.Now, let's get started by installing the home plugin and creating a simple homepage for your Backstage app.
yarn --cwd packages/app add @backstage/plugin-home
Inside your packages/app directory, create a new file where our new homepage
component is going to live. Create packages/app/src/components/home/HomePage.tsx
with the following initial code
export const HomePage = () => (
/* We will shortly compose a pretty homepage here. */
<h1>Welcome to Backstage!</h1>
);
/ routeIf you don't have a homepage already, most likely you have a redirect setup to use the Catalog homepage as a homepage.
Inside your packages/app/src/App.tsx, look for
const routes = (
<FlatRoutes>
<Navigate key="/" to="catalog" />
</FlatRoutes>
);
Let's replace the <Navigate> line and use the new component we created in the
previous step as the new homepage.
/* highlight-add-start */
import { HomepageCompositionRoot } from '@backstage/plugin-home';
import { HomePage } from './components/home/HomePage';
/* highlight-add-end */
const routes = (
<FlatRoutes>
<Navigate key="/" to="catalog" />
<Route path="/" element={<HomepageCompositionRoot />}>
<HomePage />
</Route>
</FlatRoutes>
);
Let's update the route for "Home" in the Backstage sidebar to point to the new homepage. We'll also add a Sidebar item to quickly open Catalog.
| Before | After |
|---|---|
The code for the Backstage sidebar is most likely inside your
packages/app-legacy/src/components/Root/Root.tsx.
Let's make the following changes
/* highlight-add-next-line */
import CategoryIcon from '@material-ui/icons/Category';
export const Root = ({ children }: PropsWithChildren<{}>) => (
<SidebarPage>
<Sidebar>
<SidebarLogo />
<SidebarGroup label="Menu" icon={<MenuIcon />}>
<SidebarItem icon={HomeIcon} to="catalog" text="Home" />
<SidebarItem icon={HomeIcon} to="/" text="Home" />
<SidebarItem icon={CategoryIcon} to="catalog" text="Catalog" />
<SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
<SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
<SidebarItem icon={LayersIcon} to="explore" text="Explore" />
<SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
<SidebarDivider />
</SidebarGroup>
</Sidebar>
</SidebarPage>
);
That's it! You should now have (although slightly boring) a homepage!
<!-- todo: Needs zoomable plugin -->In the next steps, we will make it interesting and useful!
There is a default homepage template (storybook link) which we will use to set up our homepage. Checkout the blog post announcement about the Backstage homepage templates for more information.
<!-- TODO for later: detailed instructions for using one of these templates. -->Composing a homepage is no different from creating a regular React Component, i.e. the App Integrator is free to include whatever content they like. However, there are components developed with the homepage in mind. If you are looking for components to use when composing your homepage, you can take a look at the collection of Homepage components in storybook. If you don't find a component that suits your needs but want to contribute, check the Contributing documentation.
If you want to use one of the available homepage templates you can find the templates in the storybook under the "Home" plugin. And if you would like to contribute a template, please see the Contributing documentation
import Grid from '@material-ui/core/Grid';
import { HomePageCompanyLogo } from '@backstage/plugin-home';
export const HomePage = () => (
<Grid container spacing={3}>
<Grid item xs={12} md={4}>
<HomePageCompanyLogo />
</Grid>
</Grid>
);