README.md
October 19, 2023 ยท View on GitHub
This is a repo that demonstrates an example of BYOC components using best practices.
Getting Started
-
To run the NextJS server just execute the following command:
npm run dev -
Then visit demo page in the browser:
Enabling BYOC in your existing app
XMC JSS app:
If your app uses JSS (for xmc next.js), BYOC will be already pre-configured upon the app generation. Simply add the components you want in byoc/index.client.tsx and index.server.tsx. Be mindful that at the time being, jss does not support async components
Regular Next.js app
-
Copy
byocfolder from this repo to yourappdirectory -
In
layout.tsxadd to the top of the file:import * as FEAAS from "@sitecore-feaas/clientside/react"; import "./byoc";And inside the layout tree itself:
<FEAAS.ExternalComponentBundle /> -
Render the component directly or as a part of FEAAS component as in
demo/page.tsx
Integrating Rendering Host for Sitecore Components
- Copy
preview-componentfolder into yourapp - In Sitecore Components app, go to Settings/Rendering Host and put in the url to that page, e.g.
https://my-website.com/preview-component - Now in the component Builder you will be able to use BYOC components and use Preview feature to see what they look like inside Sitecore components.