XPEDITE for Umbraco
The package page, with the guides to code and test generation.
How to install and configure XPEDITE, then generate a Next.js template, partial and block from Umbraco content types.
From the archive. This is from an earlier chapter of my work and may be out of date. See the archive for more like it, or the home page for what I'm doing now.
XPEDITE is a lightweight framework and code generator for Umbraco. It builds headless sites with a Next.js front end on top of Umbraco’s Delivery API, with a guided setup, generated code and generated tests. This walkthrough covers installing it, configuring it and generating each kind of component.
It takes one command, which you can generate with Paul Seal’s Package Script Writer. The script downloads the Umbraco templates, creates a project called CMS, sets the values for an unattended install and adds the XPEDITE starter kit. Run the project, open the URL it gives you, sign in, and you land on the XPEDITE home page in the backoffice.
XPEDITE walks you through setup one step at a time, and the steps update as each one is done.
Program.cs.appsettings.json. Also copy and paste, though you’ll want to change some values if you secure the API with a key.dotnet run) so it picks up the change.After that, one button creates the .env file pointing at your Umbraco instance and another creates every remaining file the app needs.
app/layout.tsx is the standard Next.js base file, and app/page.tsx is the root of the site.[...slug]/page.tsx handles every other route.Run npm run dev and the starter site comes up, with templates, partials and blocks outlined in different colours so you can tell them apart. Take those styles out once a component is finished.
Templates are tied to a document type. I picked the documentation page, chose which fields to include, and XPEDITE generated the TSX component, an example CSS file and sample tests, all wired together. One button also creates a content blueprint for the page.
I recommend a documentation page for each type of content you have. When the site is handed over, editors have a working example of every page and block to copy from.
You can download the code as a zip, but Apply to code base writes it straight into your configured folder. The one manual step is adding the line shown to templates.ts, the map between document types and React components.
Partials work with any document or element type, but compositions are the best fit because pages share them. I generated one from the page title composition, renamed the component to Header (the props were renamed to match) and ticked generic page data so the partial knows about the page it sits on. Then I added it to the documentation template, passing the props straight through.
Blocks take an element type for content and, optionally, a settings type. Both arrive as props. If the settings data type doesn’t exist yet, one button adds it to all your block lists.
My heading block has a heading level setting. Rather than display that value, I used it as the tag: uppercase the variable name so React treats it as a component, default it to h1, and render the heading with it. Add the block to its map, as with templates, and it’s done.
I added a title and a heading block to the documentation page, set the block to h2, published, and followed the link to the page in the Next.js app. Because it’s a block list, editors can add as many as they like, so I added an h3 underneath to prove it.
Search NuGet for the XPEDITE starter kit and give it a go!
The package page, with the guides to code and test generation.
The written guide to the generated test files.