This is a headless version of Wagtail's bakerydemo, built with Next.js and Wagtail API v3. It demonstrates how to use Wagtail as a headless CMS with a modern React-based frontend.
This site serves as a good demonstration of Wagtail’s built-in support for headless architectures. It requires running a copy of the Wagtail bakerydemo backend, switching to its headless branch which changes the site from serving content via HTML templates and an API to API-only mode.
- Clone this repository
- Install dependencies:
npm install- Configure your environment variables:
cp .env.example .env.localUpdate .env.local with your Wagtail backend URL.
- Start the development server:
npm run devOpen http://localhost:3000 with your browser to see the result.
- Server-side rendering of Wagtail pages
- Dynamic routing based on Wagtail page types
- Support for:
- Blog posts
- Bread types
- Locations
- Recipes
- Gallery
- Pagination for listings
- Image optimization using Next.js Image component
- Type-safe API client generated from Wagtail's OpenAPI schema
- Wagtail user bar
components/pages/- Page type components that correspond to Wagtail page modelslib/api.ts- API client, built with openapi-fetchlib/wagtail.ts- Types and helpers for data from the Wagtail APIlib/generated/- Wagtail's OpenAPI schema and the TypeScript types generated from it
The API client's types are generated from the backend's OpenAPI schema with openapi-typescript. Both the schema and the generated types are committed, so the app can be type-checked without a running backend. Whenever the backend's API changes, regenerate them with the backend running:
npm run generate-apiWhile we're not actively seeking contributions, feel free to raise issues or submit pull requests for feedback. This is an experimental project meant to demonstrate the capabilities of Wagtail as a headless CMS with Next.js.
This project is open source and available under the BSD 3-Clause License.