Create a new page using React
In this tutorial, you will learn how to create a new page and seamlessly integrate it into the admin console using MagicJS framework.
Creating a New Page
Right-click on the main-features folder and choose 'New File'.

Select 'Blank UI/React Component' and give an appropriate name to the file and click Proceed.

We will name it 'about-page’.
You will get a boilerplate UI file containing the following snippet:
import React from "react"
export default function Component(props: any) {
return <div>Hello World</div>
}Go to the "Properties" tab and set the required path in the "Page URL".

We will set its path to '/about'.
Visit the specified path
'/about'in the browser to view the output.

Note that path routing configuration in the file app.json was automatically done by mern.ai using the 'Page URL' given in the Properties tab.
🎉 That’s how you create a page in mern.ai using MagicJS framework.
Mounting a Page in Admin Console
What is mounting?
Mounting refers to assigning a specific location or path within an admin console or system to a particular page or functionality, facilitating easy navigation and access for authorized users.
Ensure the 'Starter Kit' feature is added. If not, add the 'Starter Kit' feature by asking the AI using
/add-templatetag.
We will mount a new page in the admin console that comes pre-installed with the Starter Kit.
We can easily mount a page in mern.ai with just a few clicks! Below are the steps for mern.ai as well as other IDEs.
Steps:
Create a new UI file named '
products-page' inside the main-features folder.

Change the "Hello World" to "Products" in the file as shown below:
import React from "react"
export default function Component(props: any) {
return <div>Products</div>
}Go to the properties tab.
Leave the path field empty as we are mounting this page in the admin console.
Add a mount target by clicking the + button.
Choose 'adminDashboard' from the select menu as the mount target.
Check the "Show link in sidebar" checkbox.
Set a suitable label, we will use: '
Products'.Give a link sort order, for example: '
4'.

Open the
config.jsonfile and map the file inside 'aliases' as given in the snippet below:
{
"aliases": [
{
"fileName": "products-page.tsx",
"mounts": [
{
"pageId": "adminDashboard",
"link": true,
"label": "Products"
}
]
}
]
}In the above snippet:
fileName: Specifies the file path relative to the root directory of the application.
If the file was located in a sub-folder, filename would be:
"/sub-folder/products-page.tsx"mounts: This key contains an array of objects specifying where and how the page should be mounted.
pageId: This identifies the specific location within the admin console where the page will be mounted. It corresponds to a unique identifier (pageId) defined within the application's configuration file
app.json.You can find the pageId for admin console in
app.jsonfile.link: A boolean value indicating whether the page should be linked directly in the admin console navigation. When set to
true, the page will appear as a clickable link in the sidebar.label: This is the text label that will be displayed for the mounted page in the admin console sidebar. In this case, the label is set to 'Products'.
sortOrder: Use sortOrder to specify the order in which the mounted page should appear in the admin console sidebar. Pages with lower sortOrder values will appear higher in the list.
For example: if the sortOrder is set to 2, the 'Products' page will appear second in the list.
Now, you'll find the 'Products' page seamlessly integrated into the sidebar, complete with a clickable link in the admin console.

Go to
/adminto view admin console.
🎉 That’s how you mount a page in mern.ai using MagicJS framework.
Last updated