Share this article:

Blog
Nov 04, 20224 min read

Varna and Burgas airports' websites use React components in Drupal

Varna and Burgas airports' websites use React components in Drupal

How did we end up needing React?

At Bulcode, we all ♥ Drupal, but when we first took over the support of the websites of Varna and Burgas airports, we inherited Drupal 8 systems that had been done in a way that wasn't so Drupal. As a result, the Drupal 9 migration / redevelopment was the first hurdle. For reference, you can see this article which explains the advantages of migration as well as the costs of doing nothing if you're still debating an upgrade (migration).

What makes it a challenge, exactly? Drupal 8 to Drupal 9 migration (or upgrade) is a mostly automated process, according to all sources of information. This is not always the case with most websites, especially when they are out of date with Drupal 8's most recent core and module contrib versions, so we at Bulcode always present it to clients as a small project of their own.

The inheritance we received for airport schedules was the driving force behind our decision to use React. A lot of manual work was required, as was the creation and upload of CSV files, which occasionally caused outages. It was a laborious process that occurred a few times a day. This was something that needed to be resolved as soon as possible.

So, what was our approach? With specific caching and React components for the frontend, API-driven schedules are fast and on-the-fly.

Why Drupal and React? Drupal is a content management system with a robust API for web services, and React is a simple way to build interactive user interfaces. The combination of React and Drupal works well in a number of ways. However, Drupal-powered sites can still make use of React for component development. This method is referred to as "progressive decoupling."

Now, let's see how it's put to use!

Adding React to our components: our experience

To begin, we must download and install all required dependencies:
yarn add react react-dom webpack webpack-cli @babel/cli @babel/core @babel/preset-env @babel/preset-react babel-loader webpack webpack-cli

Please note that we are not going to discuss the specifics of how each module works or which ones should be added as dev dependencies here. Using the packages page, you can see this.

Let's now set up our package.json scripts section:
package json scripts

Having separate dev and production webpack configurations is a good idea, so keep this in mind when creating your own files.

Add a simple webpack.config.js to the mix. React Hot Reloader with Webpack Server, some CSS, SASS, and file loaders, as well as additional plugins such as ESLint and minifiers are likely to be needed in your work. We won't go into this here because it's a matter of personal preference.

webpack config

Let's not forget our babel configs. This can be done using package.json or .babelrc.

babel config

We're getting closer and closer. In our dist folder, we'll find an app.bundle.js that we can use as a library in our theme when our build scripts are run. For ease of implementation, we'd like to add it to the entire app. Note that the performance of your application may be compromised if you only need React for a few components scattered across random pages.

app bundle js

We're ready to get started on our actual react component. The sky's the limit in this section.

src/index.jsx

react component

Finally, we'll add the markup required to display our React component. It's up to you now to put it where you want!

html

And voilà, we successfully integrated React into our Drupal project.

 

Fraport Bulgaria
”The individual approach, timely deliveries and precise documentation of the developments are a small part of the reasons for continuing the active partnership with Bulcode 2016 Ltd. It is our privilege and obligation to recommend the team of Bulcode 2016 Ltd. as extremely competent, reliable, and responsible in the implementation of the commitments.”

SUBSCRIBE TO OUR NEWSLETTER

Share this article:

SUBSCRIBE TO OUR NEWSLETTER

Related Blog Articles

    Why startups hesitate to work with a bespoke software development agency – and how we address every concern

    Blog

    Why startups hesitate to work with a bespoke software development agency – and how we address every concern

    Startups often hesitate to work with software agencies due to concerns over cost, control, and flexibility. Discover how Bulcode’s bespoke software solutions address each challenge, ensuring growth and agility.

    Written by Svetoslava Angelova
    Nov 05, 20245 min read
    Building a high-performing Agile team: Our proven approach

    Blog

    Building a high-performing Agile team: Our proven approach

    Discover how we build high-performing Agile teams by defining clear roles, fostering collaboration, and using flexible tools.

    Written by Svetoslava Angelova
    Aug 27, 20248 min read
    Drupal 11: What to expect? Comprehensive guide to new features and enhancements

    Blog

    Drupal 11: What to expect? Comprehensive guide to new features and enhancements

    Drupal 11 is out! In this article, discover it's exciting features and improvements. Upgrade now to redefine your digital strategy with Bulcode's expert support.

    Written by Svetoslava Angelova
    Aug 05, 20247 min read
    Single Directory Components in Drupal core: A comprehensive overview

    Blog

    Single Directory Components in Drupal core: A comprehensive overview

    Explore how Single Directory Components (SDC) in Drupal Core streamline the development process by encapsulating component-related files into a single directory. Learn about the benefits of SDCs and follow a step-by-step guide to implement them in your Drupal projects.

    Written by Nikolay Tsekov
    Aug 07, 20244 min read
    Scrum events

    Blog

    Scrum events

    Scrum defines several events (sometimes called ceremonies) that occur inside each sprint: sprint planning, daily scrum, sprint review, and sprint retrospective.

    Written by Svetoslava Angelova
    Nov 22, 20223 min read
    Scrum artefacts

    Blog

    Scrum artefacts

    In software development, the term “artefact” refers to information that stakeholders and the scrum team use to describe a product that’s being developed.

    Written by Svetoslava Angelova
    Nov 23, 20222 min read
    Headless Drupal with Next.js - simple example walkthrough

    Blog

    Headless Drupal with Next.js - simple example walkthrough

    The trend recently, in web development in general, and consequently in Drupal development is to use the technology headless. The trend recently, in web development in general, and consequently in Drupal development is to use the technology headless.

    Written by Mihail Shahov
    Jan 13, 20237 min read
    Hire dedicated software developers (teams)

    Blog

    Hire dedicated software developers (teams)

    Tired of raising expenses with your in-house development team? Why not get a dedicated team at 40% to 60% of the cost?

    Written by Mihail Shahov
    Jul 17, 20203 min read
    The importance of the right development partner in your software development life cycle

    Blog

    The importance of the right development partner in your software development life cycle

    Unlocking success: The art of choosing the perfect software development partner. Explore the pivotal role of partners in software development, uncover ROI secrets, and stay ahead of industry trends in this must-read article.

    Written by Mihail Shahov
    Sep 26, 20238 min read
    Config split module tutorial for Drupal

    Blog

    Config split module tutorial for Drupal

    Very often we as developers need to work with different environments. This could sometimes lead to (un)expected problems. In Drupal 8 we use the configuration system which works pretty nice, but there are cases where the settings for the local and any other environment should be different.

    Written by Ivaylo Tsandev
    May 20, 20217 min read
    Unveiling the power duo: Next.js as the Headless frontend of Drupal 10

    Blog

    Unveiling the power duo: Next.js as the Headless frontend of Drupal 10

    Discover the dynamic synergy between Drupal 10 and Next.js, as this powerful combination reshapes the landscape of web development. Next.js, an open-source React-based framework, is seamlessly integrated as the headless frontend of Drupal 10, offering a plethora of benefits. From enhanced performance with features like automatic code splitting and server-side rendering to flexible design and SEO-friendly capabilities, this collaboration empowers developers to create high-performing, scalable, and visually appealing web applications. The efficient content management of Drupal 10 coupled with Next.js' adaptability to trends ensures a cutting-edge development approach, positioning this tandem at the forefront of modern web development practices. Embrace the future with the Drupal 10 and Next.js combination, redefining how we approach and craft dynamic online experiences.

    Written by Todor Kolev
    Feb 07, 20245 min read
    Config ignore module tutorial for Drupal

    Blog

    Config ignore module tutorial for Drupal

    Sometimes we don't want our configurations to be shared in the codebase. So what can we do in such cases?

    Written by Ivaylo Tsandev
    Jul 27, 20217 min read

    GET IN TOUCH

    Have a project you'd like to launch?