kirby
nuxt-kirby

Fetch Kirby CMS data via KQL or the REST API

Nuxt Kirby module

Nuxt Kirby

Kirby CMS data in Nuxt, via KQL or the REST API.

Features

  • 🔒 Protected Kirby credentials on every request
  • 🪢 Supports token-based authentication with the Kirby Headless plugin (recommended)
  • 🍱 Handle requests just like with the useFetch composable
  • 🦦 Multiple starter kits available
  • 🗃 Cached query responses
  • 🤹 No CORS issues
  • 🦾 Strongly typed

Setup

Add the module to a project on Nuxt 4.6 or a later Nuxt 4 release:

npx nuxt module add kirby

Basic Usage

Set your Kirby credentials in .env. This example uses basic authentication with the KQL plugin; Getting Started sets up token authentication instead:

NUXT_KIRBY_URL=https://kirby.example.com
NUXT_KIRBY_CREDENTIALS_USERNAME=your-username
NUXT_KIRBY_CREDENTIALS_PASSWORD=your-password

And send queries in your template:

<script setup lang="ts">
const { data, error, status } = await useKql({
  query: 'site'
})
</script>

<template>
  <div>
    <h1>{{ data?.result?.title }}</h1>
    <pre>{{ JSON.stringify(data?.result, undefined, 2) }}</pre>
  </div>
</template>

The documentation covers authentication, multi-language sites and every module option.

💻 Development

  1. Clone this repository
  2. Enable Corepack using corepack enable
  3. Install dependencies using pnpm install
  4. Run pnpm run dev:prepare
  5. Start development server using pnpm run dev

License

MIT License © 2022-PRESENT Johann Schopplich