Key Takeaways
Introduction
In this tutorial we set up a Drupal 9 environment and a basic React application that can view, alter, create, and remove content. The API service is Drupal core's JSON:API module.
The original tutorial used Drupal 9, React, Axios, react-router-dom, and a custom Vehicle content type with a body and image field. It is kept here as a legacy article because it reflects an earlier stage of my work with decoupled Drupal and frontend applications.
Setting up Drupal
The first step is creating a Drupal 9 project with Composer, installing the site, enabling JSON:API and Serialization, and creating a custom Vehicle content type. The Vehicle content type contains a body field and an image field called vehicle_image.
After creating sample vehicle content, the JSON:API endpoint can be tested at /jsonapi/node/vehicle. To create, edit, and remove content from the React app, the required Drupal permissions and CORS settings need to be configured.
Legacy security note
This is a preserved legacy tutorial from 2021. The CORS and Basic Auth examples below were written for a local learning setup and should not be copied as production security guidance. Modern Drupal, frontend tooling, authentication, and deployment practices should be reviewed before using these patterns in a real project.
Drupal setup screenshots



A selection of screenshots from the original Drupal 9 setup flow.
composer create-project drupal/recommended-project my_site_name_dircors.config:
enabled: true
allowedHeaders: [ 'x-csrf-token','authorization','content-type','accept','origin','x-requested-with','access-control-allow-origin','x-allowed-header','*' ]
allowedMethods: [ '*' ]
allowedOrigins: [ 'http://localhost/','http://localhost:3000','http://localhost:3001','http://localhost:3002','*' ]
exposedHeaders: false
maxAge: false
supportsCredentials: trueCreating the React application
The React application is based on create-react-app. The tutorial adds Axios for HTTP requests and react-router-dom for routing. The app is structured around Header, Navigation, Content, Footer, and Vehicle components.
npx create-react-app tutorial-react-decoupled
npm i axios
npm i react-router-dom
npm startimport './App.css';
import './Form.css';
import Header from './components/Header/Header';
import Content from './components/Content/Content';
import Footer from './components/Footer/Footer';
function App() {
return (
<div className="App">
<Header />
<Content />
<Footer />
</div>
);
}
export default App;import axios from "axios";
export default axios.create({
baseURL: "{YOURSITEURL}/jsonapi",
headers: {
"Accept": "application/vnd.api+json",
"Content-type": "application/vnd.api+json",
"Authorization": "Basic " + btoa('USER:PASSWORD'),
}
});import http from "../http";
import axios from "axios";
class VehicleDataService {
getAll() {
return http.get("/node/vehicle?include=field_vehicle_image");
}
get(id) {
return http.get(`/node/vehicle/${id}?include=field_vehicle_image`);
}
create(data) {
return http.post("/node/vehicle", data);
}
update(id, data) {
return http.patch(`/node/vehicle/${id}`, data);
}
delete(id) {
return http.delete(`/node/vehicle/${id}`);
}
upload(id, file) {
return axios({
method: "post",
url: `{YOURURLHERE}/jsonapi/node/vehicle/${id}/field_vehicle_image`,
headers: {
"Accept": "application/vnd.api+json",
"Content-type": "application/octet-stream",
"Authorization": "Basic " + btoa('USER:PASSWORD'),
"Content-Disposition": `file;filename="${file.name}"`,
},
data: file,
});
}
}
export default new VehicleDataService();Routing and components
The Content component uses routes for the vehicle list, the add/edit form, and the vehicle detail page. The list component fetches vehicles from Drupal JSON:API, maps the included image data, and renders cards for each vehicle. The detail component fetches one vehicle by ID and provides links for editing and deleting.
The final form component handles both create and update flows, including optional image upload. This was intentionally simple: the goal was to demonstrate a full CRUD loop against Drupal JSON:API, not to build a production-grade admin interface.
Finished React application

The finished React CRUD application from the original tutorial.
Closing note
This is a legacy tutorial from an earlier phase of my work. Some package APIs and best practices have changed since publication, but the architectural idea remains useful: expose structured content through Drupal JSON:API, isolate request logic in services, and keep the frontend components focused on rendering and user interaction.