SR
Click to open github profile

Js Craft CMS Query API

The core package for Vue and Nuxt Craft CMS. Use this as a foundation to build a query builder for Craft CMS with your preferred JavaScript framework.

Features

  • Support for Main Element Types: Query addresses, assets, entries and users.
  • Helper for Preview Mode: Easily add preview mode to your headless setup.
  • Typesafe: Built with typescript in mind.
  • Easy Adaptable: You can easily build your own custom wrapper with that core logic.

Examples

Want to see how it works?

app.ts
import { buildCraftQueryUrl } from 'js-craftcms-api';

// Build URL for fetching a single address
const url = buildCraftQueryUrl('entries')
  .id(1)
  .status('active')
  .siteId(1)
  .buildBaseUrl('one');
// Result: /v1/api/queryApi/customQuery?elementType=addresses&id=1&status=active&siteId=1&one=1

It is as simple as that. 🚀

Further Resources


Copyright © 2024 Samuel Reichör