Use Craft CMS Query Builder in Nuxt
With the Nuxt Craft CMS module, you can easily integrate Craft CMS and leverage the Craft Query Builder in your Nuxt projects.
Features
- Query builder: Easily build and execute queries directly from Nuxt, enabling flexible, real-time data retrieval from Craft CMS
- Built in Helper Components: Connect your data directly with your Vue components, to speed up development.
- Get Only the Data You Need: Avoid overfetching by using a custom function in the query builder to select only the fields you require.
- Pretty Json: Json Transformer are in place to prettify the response.
- Support for Main Element Types: Query addresses, assets, entries and users.
- Full Typescript Suppport: Craft Query Builder with typescript support pretty cool hah?😎
Examples
Want to see how it works?
app.vue
const { data, error } = await useCraftQuery('entries')
.section('news')
.fields(['title']) // add more field handles if you like
.limit(3)
.all()
if (error.value) {
console.error(error.value)
}
It is as simple as that. 🚀 The response will be the entry with id 1.
Further Resources
- Craft Query API: A Craft CMS Plugin, that powers this stuff.
- Vue Craft CMS: A package to use the query builder in Vue.
- Js Craft CMS API: The core package, you can build wrappers around it to support your framework. If you want to build a wrapper around it for your framework -> Hit me up :)