Explore headless rendering of Drupal contents using various front-end approaches with REST in this experimental repository. Note that it belongs to my personal lab and is not suitable for production websites without proper adaptation.
- DDEV v1.2+ with Docker
- PHP 8.2+
- Composer 2.5+
- Go to the Drupal 10 directory:
cd drupal10
. - Install the Composer dependencies:
composer install
. - Start the DDEV Docker containers:
ddev start
. - Install the Drupal website – the "Drupal Headless" distribution profile will be used:
ddev drush si -y
. - Generate a few dummy articles:
ddev drush devel-generate:content 10 --bundles='article'
. - Clear Drupal caches
ddev drush cr
.
The project can be reached at http://drupal10.ddev.site
Articles collection:
GET /api/v1/articles
.
Article by ID:
GET /api/v1/articles/[id]
.
💡 you can import the drupal10/drupal_headless.postman_collection.json collection into Postman to test all the available endpoints more quickly.
- SSH into the web container
ddev ssh
. - Execute PHPUnit passing the Articles module directory parameter
./vendor/bin/phpunit ./web/modules/custom/articles
- Go to the Next.js directory:
cd next.js
. - Install the Node dependencies:
npm install
. - Start the Next.js dev environment:
npm run dev
The project can be reached at http://localhost:3000