This is a repo that demonstrates an example of BYOC components using best practices.
-
To run the NextJS server just execute the following command:
npm run dev
-
Then visit demo page in the browser:
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
-
Copy
byoc
folder from this repo to yourapp
directory -
In
layout.tsx
add 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
- Copy
preview-component
folder 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.