How To Run PageBuilder Engine Locally - Starting from scratch with Hello World example
Video Tutorial
Here is a 10 minute video version of this tutorial. You can use this page for copy/paste ready snippets for the steps we are walking through in the video.
If you havenβt reviewed yet, for general local development environment notes and system requirements, see introduction notes in How To Run PageBuilder Engine Locally article.
Initialize fusion-cli
Starting from scratch is easy. PageBuilder Engine CLI (fusion-cli) have an init method that bootstraps an empty project. To do that create a folder in your development environment, navigate to the folder and run npx @arc-fusion/cli init
mkdir hello-worldcd hello-worldnpx @arc-fusion/cli init
This command will copy bootstrap folder structure then install npm dependencies.
The folder structure for the empty project will be:
.βββ componentsβ βββ chainsβ β βββ div.jsxβ β βββ generatorsβ β β βββ list.jsxβ β βββ ordered-list.jsxβ β βββ unordered-list.jsxβ βββ featuresβ βββ layoutsβ βββ output-typesβ βββ default.jsxβββ contentβ βββ schemasβ βββ sourcesβ βββ 404.jsβββ dataβ βββ dumpsβ βββ restoreβββ environmentβ βββ README.mdβββ mocksβ βββ appsβ βββ dashboard.jsonβ βββ settingsβ β βββ apiβ β βββ v1β β βββ userβ β βββ pinnedβ βββ siteserviceβ β βββ apiβ β βββ v3β β βββ websiteβ βββ userβββ package-lock.jsonβββ package.jsonβββ propertiesβ βββ README.mdβ βββ sitesβββ resources βββ README.md
Create your first component
Now you can create a new feature under components/features folder with creating a component folder, letβs call it Greet
and default.jsx
inside the folder.
Letβs add a plain component with a custom field:
import React from 'react';import PropTypes from '@arc-fusion/prop-types';
const Greet = ({ customFields }) => ( <div className="hello_text"> Hello {customFields.name || 'User'} ! </div>);
Greet.propTypes = { customFields: PropTypes.shape({ name: PropTypes.string.tag({ label: 'Name', description: 'What is your name?', }), }),};
export default Greet;
If you havenβt started PageBuilder, now itβs time to run npx fusion start
command which will download required docker images, spin up containers and build your project. Keep in mind that a lot goes on when you start PageBuilder because fusion-cli tries to simulate Arc XP environment with its micro services in your local environment. Once the build is complete, youβll see a message:
fusion-webpack |fusion-webpack | .d8888b. 88d888b. .d8888b. dP. .dP 88d888b.fusion-webpack | 88' `88 88' `88 88' `"" `8bd8' 88' `88fusion-webpack | 88. .88 88 88. ... .d88b. 88. .88fusion-webpack | `88888P8 dP `88888P' dP' `dP 88Y888P'fusion-webpack | 88fusion-webpack | dPfusion-webpack |fusion-webpack | Webpack build completed in 27501 ms.fusion-webpack |fusion-webpack | You can now view PageBuilder Editor in your browser:fusion-webpack | http://localhost/pagebuilder/pagesfusion-webpack |
Now you can visit http://localhost/pagebuilder/pages to see PageBuilder Editor tool.
By default, youβll have an empty PageBuilder. There wonβt be any pages, templates.
Create a page
Click βCreate Pageβ button to open create page popup.
Give your page a title and a URI. Page URI has to be unique in PageBuilder. Then click Create.
You will be redirected to PageBuilder Editor interface where the magic happens.
Curate page and configure blocks
Now click the βCurateβ workspace from the left sidebar.
You will see the first panel showing your page layout. Depending on the βlayoutβ you chose (there will be no layout in the beginning until you create one), youβll see sections of your layout that you can βAdd Blockβs to your page.
When you click βAdd Blockβ, a second panel will open up, showing list of all available blocks form your bundle.
When a block is added to the page, or when an Editor staff clicks to the particular feature in the curation panel, they see the secondary panel for configuration options for that block. In this panel, there are general information for the selected block, but more importantly custom fields displayed that your Editor staff can easily configure a block. An Editor staff member can add same block over and over again with different configuration. In this example, an Editor staff could add Greet block multiple times with configuring each with different name. And Engine will render each block instance separately with that configuration.
PageBuilder Editor, shows a preview of the page on the right side and this preview gets re-rendered on every change, so your Editor staff can easily see changes they are making on a page in this preview.
Publish the page
Now itβs time to publish your page. Navigate to Publish workspace on the left sidebar. Then click βShare and Publishβ link.
Test your page
Once page is published, you can access it with 2 methods.
a) Click page URL from PageBuilder Editor:
b) Entering its URI directly on the PageBuilder rendering path like:
http://localhost/pf/test/
The /pf/
prefix in the path is omitted in the Arc XP render stack and in live URLs. It is required in local development environment since PageBuilder local stack uses localhost (80) to expose both PageBuilder Editor administrative UI as well as rendering engine that resides under /pf/
path.
This wraps up our tutorial to create a plain Hello World page in PageBuilder.