You can use JSON:API directly inside Drupal Canvas code components to pull dynamic content from your site.
This means your components can query any content type, taxonomy, or entity and display live data without leaving the Canvas interface.
Here's how to set it up:
- Install the JSON:API module and the Drupal Canvas dev mode module
- Navigate to your component library and create a new code component
- Import the required libraries at the top of your component: json-api-client, drupal-jsonapi-params
- Write your component to fetch and display the data using standard React patterns with useSWR
Your component will now fetch live content from your Drupal site using JSON:API.
#drupal #drupalcms
Full Tutorial and video: https://www.webwash.net/drupal-cms-v2-alpha1-drupal-canvas/
Join our newsletter, https://www.webwash.net/newsletter/