Add a new page
This article describes how to add a new page in the app.
Overview
This article describes how to add a new page in the app.
Current working directory is the packages/<package-id> folder.
Create a new page
To create a new page, you need to create a new React component and add it to the app. To do this, follow these steps:
-
Open the
<package-id>/pagesfolder or create a new one if it does not exist. -
Create a new React component in the
pagesfolder. You can usepages/CustomPage.jsas a reference.const CustomPage = { title: 'Custom Page', blocks: [ { name: 'namespace/custom-block',// custom block name attributes: { title: 'Title from app', }, }, ], }; export default CustomPage;You need to register the block in the
blocksfolder. For more information, see Add a new block. -
Register the page in the
pages/index.jsfile.import CustomPage from './customPage'; const pages = { 'custom-page': CustomPage, } export { pages } -
Import the page in the
<package-id>/index.jsfile.import { pages } from './pages/index'; -
You can then use the page in the app. For example, you can link this page to a tab in the navigation bar.
{ name: 'appmaker/nav-tab-item', clientId: 'nav-tab-item-1', attributes: { tabId: 'home', title: 'Home', iconName: 'home', pageId: 'CustomPage', }, },