A boilerplate is a fitting template to describe distinct repetitive segments of a project to help build projects quickly and efficiently.
They can define project-level elements or standard methods for one or more projects.
The following guide shows how to build an ecommerce marketplace app using our Marketplace Ecommerce App Boilerplate. For more information about the Marketplace Ecommerce App Boilerplate, you can check the GitHub repository here.
The boilerplate folder structure consists of relative files and references, making it easy to acclimate within your project. This structure also allows the boilerplate to be thoroughly portable between different stacks in Contentstack.
Below is the folder structure of the boilerplate:
marketplace-ecomm-boilerplate-app
|-- api
|-- constants
| |-- index.js
|-- handler
| |-- index.js
|-- root_config
| |-- index.js
|-- .eslintrc.js
|-- index.js
|-- package-lock.json
|-- package.json
|-- example
|-- sapcc
| |-- api
| | |-- root_config
| | |-- index.js
| |-- ui
| | |-- root_config
| | |-- index.js
|-- bigcommerce
| |-- api
| | |-- root_config
| | |-- index.js
| |-- ui
| | |-- root_config
| | |-- index.js
|-- ui
|-- public
| |-- favicon.ico
| |-- index.html
|-- .env
|-- src
| |-- assets
| | |-- Logo.svg
| |-- common
| | |-- constants
| | |-- index.ts
| | |-- contexts
| | |-- appConfigurationExtensionContext.ts
| | |-- categoryCustomFieldExtensionContext.ts
| | |-- customFieldExtensionContext.ts
| | |-- entrySidebarExtensionContext.ts
| | |-- marketplaceContext.ts
| | |-- productCustomFieldExtensionContext.ts
| | |-- selectorExtensionContext.ts
| | |-- hooks
| | |-- useAppConfig.ts
| | |-- useAppLocation.ts
| | |-- useAppSdk.tsx
| | |-- useCategoryCustomField.tsx
| | |-- useCustomField.tsx
| | |-- uuseFrame.ts
| | |-- useInstallationData.tsx
| | |-- useProductCustomField.tsx
| | |-- useSdkDataByPath.ts
| | |-- locale
| | |-- index.ts
| | |-- providers
| | |-- AppConfigurationExtensionProvider.tsx
| | |-- CategoryCustomFieldExtensionProvider.tsx
| | |-- CustomFieldExtensionProvider.tsx
| | |-- EntrySidebarExtensionProvider.tsx
| | |-- MarketplaceAppProvider.tsx
| | |-- ProductCustomFieldExtensionProvider.tsx
| | |-- SelectorExtensionProvider.tsx
| | |-- types
| | |-- index.ts
| | |-- utils
| | | |-- index.tsx
| |-- components
| | |-- ErrorBoundary
| | |-- index.tsx
| | |-- WarningMessage
| | |-- index.tsx
| | |-- styles.scss
| |-- containers
| | |-- App
| | | |-- index.tsx
| | | |-- styles.scss
| | |-- CategoryField
| | | |-- index.tsx
| | |-- ConfigScreen
| | | |-- index.spec.tsx
| | | |-- index.tsx
| | | |-- styles.scss
| | |-- CustomField
| | | |-- Category.tsx
| | | |-- DeleteModal.tsx
| | | |-- DraggableGrid.tsx
| | | |-- DraggableListItem.tsx
| | |-- DraggableListItemCategory.tsx
| | | |-- index.spec.tsx
| | | |-- index.tsx
| | | |-- ListItem.tsx
| | | |-- Product.tsx
| | | |-- RenderList.tsx
| | | |-- styles.scss
| | |-- ProductsField
| | | |-- index.tsx
| | |-- SelectorPage
| | | |-- index.tsx
| | | |-- styles.scss
| | |-- SidebarWidget
| | | |-- index.tsx
| | | |-- ProductDescription.tsx
| | | |-- styles.scss
| |-- root_config
| | |-- index.ts
| |-- services
| | |-- index.ts
| |-- types
| | |-- index.d.ts
| |-- index.css
| |-- index.tsx
| |-- react-app-env.d.ts
| |-- reportWebVitals.ts
| |-- .babelrc
|-- .eslintrc
|-- config.overides.js
|-- jest.config.js
|-- jest.CSStub.js
|-- jest.setup.js
|-- package-lock.json
|-- package.json
|-- tsconfig.json
|-- update-app-info.json
└─ .gitignore
└─ LICENSE
└─ README.md
└─ SECURITY.md
└─ build.sh
└─ package.lock.json
└─ package. jsonBelow are the app routes for each location in App.tsx:
function App() {
return (
<ErrorBoundary>
<MarketplaceAppProvider>
<Routes>
<Route path="/" element={<HomeRedirectHandler />} />
<Route
path="/custom-field"
element={
<Suspense>
<CustomFieldExtensionProvider>
<CustomFieldExtension />
</CustomFieldExtensionProvider>
</Suspense>
}
/>
<Route
path="/entry-sidebar"
element={
<Suspense>
<EntrySidebarExtensionProvider>
<EntrySidebarExtension />
</EntrySidebarExtensionProvider>
</Suspense>
}
/>
<Route
path="/config"
element={
<Suspense>
<AppConfigurationExtensionProvider>
<AppConfigurationExtension />
</AppConfigurationExtensionProvider>
</Suspense>
}
/>
<Route
path="/product-field"
element={
<Suspense>
<ProductCustomFieldExtensionProvider>
<ProductExtension />
</ProductCustomFieldExtensionProvider>
</Suspense>
}
/>
<Route
path="/category-field"
element={
<Suspense>
<CategoryCustomFieldExtensionProvider>
<CategoryExtension />
</CategoryCustomFieldExtensionProvider>
</Suspense>
}
<Route
path="/selector-page"
element={
<Suspense>
<SelectorExtensionProvider>
<SelectorExtension />
</SelectorExtensionProvider>
</Suspense>
}
</Routes>
</MarketplaceAppProvider>
</ErrorBoundary>
);
}To get started with building applications using the boilerplate, follow the steps given below:
Create a .env file and provide the URLs to configure the app.
For example:
In the terminal, go to the APP_DIRECTORY and install the necessary dependencies.
cd <APP_DIRECTORY>npm i
For UI
cd <APP_DIRECTORY>/uinpm i
npm run start
npm run startWin
For API
cd <APP_DIRECTORY>/apinpm i
npm run dev
To use your application, you need to upload it to Contentstack. To do so, perform the steps given below:


Warning: While selecting the Type of App in the above step, ensure you select Stack App, as this boilerplate supports stack apps only.


Note: The name for each UI Location is optional, and can be used to override the default app name.



Note: After adding each route save and install the app in any stack.


Let’s understand the configuration fields:
Note: This configuration is a template for the user to understand how they can add/update/remove the config fields and add customized fields based on their requirement.

Note: With Save in Entry field, If you select the ''Custom Fields'' option, you can select the structure of the data you want to save in the entry. If the 'All Fields' option is selected, you might be able to add limited products in the custom field depending on the size of the data (Refer to the Custom Fields Limitations documentation, for more details). To increase this limit, Items Per Page defines the number of products to be displayed on the selector screen.
Additional Resource: To learn more, refer to the App Configuration document.
Having the basic ecommerce app setup ready, you can now update root_config files in the UI and API directories. You can go through the Template.MD file in our code repository documentation for complete details on root_config and update it as per the ecommerce platform that you are trying to integrate.
Note: In the root_config file, you can add the name of your app, the selector page information, etc. You can add details about the configuration screen as well.
You can check examples of some ecommerce websites, such as BigCommerce and SAP Commerce Cloud in the GitHub code you downloaded to get started. To do so, follow the steps below:
For API
For UI
Restart both the servers for UI and API using the npm command as shown above.
Note: You must open the app in the configured UI location to view it.
To use the Ecommerce application within an entry of your stack, follow the steps given below:







