UNPKG

nuxt-kql

Version:

Kirby's Query Language API for Nuxt

71 lines (51 loc) โ€ข 1.87 kB
[![Nuxt KQL module](./docs/public/og.jpg)](https://nuxt-kql.byjohann.dev) # Nuxt KQL [Nuxt](https://nuxt.com) module for [Kirby's Query Language](https://github.com/getkirby/kql) API. - [โœจ &nbsp;Release Notes](https://github.com/johannschopplich/nuxt-kql/releases) - [๐Ÿ“– &nbsp;Read the documentation](https://nuxt-kql.byjohann.dev) ## Features - ๐Ÿ”’ Protected Kirby credentials when sending queries - ๐Ÿชข Supports token-based authentication with the [Kirby Headless plugin](https://github.com/johannschopplich/kirby-headless) (recommended) - ๐Ÿคน No CORS issues! - ๐Ÿฑ Handle request just like with the [`useFetch`](https://nuxt.com/docs/getting-started/data-fetching/#usefetch) composable - ๐Ÿ—ƒ Cached query responses - ๐Ÿฆฆ [Multiple starter kits](https://nuxt-kql.byjohann.dev/guide/starters) available - ๐Ÿฆพ Strongly typed ## Setup > [!TIP] > [๐Ÿ“– Read the documentation](https://nuxt-kql.byjohann.dev) ```bash npx nuxi@latest module add kql ``` ## Basic Usage > [!TIP] > [๐Ÿ“– Read the documentation](https://nuxt-kql.byjohann.dev) Add the Nuxt KQL module to your Nuxt config: ```ts // `nuxt.config.ts` export default defineNuxtConfig({ modules: ['nuxt-kql'] }) ``` And send queries in your template: ```vue <script setup lang="ts"> const { data, refresh, error, status, clear } = await useKql({ query: 'site' }) </script> <template> <div> <h1>{{ data?.result?.title }}</h1> <pre>{{ JSON.stringify(data?.result, undefined, 2) }}</pre> </div> </template> ``` ## ๐Ÿ’ป Development 1. Clone this repository 2. Enable [Corepack](https://github.com/nodejs/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) License ยฉ 2022-PRESENT [Johann Schopplich](https://github.com/johannschopplich)