2

I'm building a static webpage with php and Javascript. I have setup all my data in craft cms entries. I want to use ajax to retrieve the data from craft and just display it on my webpage. How do I do this?

1 Answer 1

2

You'll need to expose some sort of API that your JavaScript can use to request data from your Craft install.

There are two first-party options:

  1. Craft CMS has had GraphQL support built into core since version 3.3.0. The official docs provides a fairly comprehensive guide to get up and running.

  2. If you prefer a RESTful JSON API, the first-party Element API plugin provides a simple interface to configure your endpoints. The documentation for Element API can be found on the plugin's GitHub page. The Element API plugin is available for both Craft 3 and 4.

Aside from the above, if you happen to use Gatsby for your site there's also a first-party Gatsby source plugin for Craft.

Finally, when using Craft as a CMS for a headless app/site, it's also worth knowing about the headlessMode, which "optimizes the system and control panel for headless CMS implementations".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.