Headless

Getting Started

The Kirby Headless plugin enhances your Kirby site with headless capabilities.

Introduction

This plugin is designed for developers who want to use Kirby's backend to serve content to a frontend application, static site generator, or mobile application. You can either add headless functionality to your existing Kirby site, or use this plugin to build a headless-first CMS from scratch.

Check out to the Kirby Headless Starter repository for a ready-to-use headless-only setup!

Key Features

  • ๐Ÿงฉ Optional bearer token authentication for KQL and custom API endpoints
  • ๐Ÿงฑ Resolve fields in blocks: UUIDs to file and page objects or any other field
  • โšก๏ธ Cached KQL queries
  • ๐ŸŒ Multi-language support for KQL queries
  • ๐Ÿ˜ต Built-in CORS handling
  • ๐Ÿข Express-esque API builder with middleware support
  • ๐Ÿ—‚ Return JSON from templates instead of HTML

Installation

Composer

The recommended way to install the plugin is via Composer. To install the plugin, run the following command in your terminal:

composer require johannschopplich/kirby-headless

Download

Head over to the releases page and download the latest version of the plugin as a ZIP file. Extract the contents of this ZIP file to your site/plugins folder. It should look like this:

site/plugins/
โ”œโ”€ kirby-headless/
โ”‚  โ””โ”€ โ€ฆ Plugin files

Setup

Nothing to do here! The plugin is ready to use out of the box. If you want to customize the plugin, you can do so by configuring it.

By default, Kirby Headless does not interfere with Kirby's default routing. Thus, it won't affect your existing routes or templates.