VOOZH about

URL: https://thenewstack.io/from-php-to-next-js-what-trivago-learned-rewriting-its-web-app/

⇱ From PHP to Next.js: What Trivago Learned Rewriting Its Web App - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-05-19 03:00:06
From PHP to Next.js: What Trivago Learned Rewriting Its Web App
profile,
Open Source / Software Development

From PHP to Next.js: What Trivago Learned Rewriting Its Web App

May 19th, 2022 3:00am by Jessica Wachtel
👁 Featued image for: From PHP to Next.js: What Trivago Learned Rewriting Its Web App

Hotel search service Trivago rewrote its frontend in Typescript on the Next.js framework, replacing a PHP codebase on a homegrown JavaScript framework, Melody. From April 2020 until late 2021 the platform team created, tested and deployed the new application which reduced page size by up to 37%, while increasing daily code releases.

Engineering is all about tradeoffs, and Tom Bartel, Trivago Team Lead Interface Platform, does an excellent job illustrating the tradeoffs that led to the platform rewrite in his recent blog post. It was a massive undertaking, especially when nothing is inherently “wrong” or broken with the codebase.

What was working? Well, the site at large was. Users were enjoying full functionality on the web and mobile. There was a trained engineering team with many who enjoyed their functional job duties.

What “wasn’t working”? Melody was homegrown so it wasn’t widespread. The ecosystem was small, documentation was limited, and the engineering goes to’s (i.e. Google and Stack Overflow) were very limited or no help at all. There were at max two core maintainers with at least one on-call at all times. It was challenging to onboard new employees and some voiced concerns that they were learning and nurturing non-transferable skills.

Double down on Melody? Allocate resources to modernize the framework, update and add quality documentation, and train engineers to maintain? Or stare down …

…The Blank Page

It’s not a new project but it is a new project. Since the effort, internally called the Web Application Rewrite Project (WARP), is a complete rewrite and not a refactor, all the new project questions arise:

  • Libraries: which are most appealing for utilities, date calculation, etc…?
  • CSS Files: how to organize?
  • Application state: how will this get maintained?
  • Event transmission: how will this take place?
  • HTML pages: will this get statically pre-generated?
  • Structure: for URLs and pages.
  • Application initialization: how will it work?
  • Component APIs: What will the design look like?

Decisions, Decisions!

With so many decisions and the team working remotely (remote collaboration was still considered new back when this project started in April of 2020), the Trivago engineers implemented an incredibly methodic, pragmatic approach to tackling the touch engineering questions and ultimately reaching the decisions.

  • Decision document: this document collected and organized the engineer’s relevant facts and viewpoints.
  • Decision meeting: a place for discussion of viewpoints leading ultimately to the decision.
  • Decision owner: curates the document, prepares the decision meeting and makes sure a decision is formed.

Some decisions were easy to arrive at while others were hard-won, some made it from document to testing while others were refactored as implementation didn’t meet the original expectations.

It was during the implementation of another decision that felt too complicated for some developers that Trivago engineers decided to move forward with Next.js and React.

A great piece of advice coming from the Trivago trial and error rewrite process is to get committed to decisions but keep an open mind and course-correct when necessary. Decisions made with the best knowledge and intentions may bring new insights during implementation.

Almost There

Once the rewrite was fully functional and useful to the user, it was exposed to the real world and tested with dashboards, checks, and comparisons serving as guides for the engineers to see what needed attention.

👁 Trivago dashboards

  • User Interaction: Does this differ between products? If so, was the cause bugs or something else?
  • Revenue: Does the new application forward to booking sites at the same rate?
  • Search Types: Trivago automatically adjusts search types for better results. For example, if a search is too narrow, Trivago will expand the parameters and add results. A direct indicator that something was off is a difference in listings. This caused the further investigation.

👁 map functionality

It took several months of engineering but finally, the switch was flipped and all user traffic went to the new application.

Rewards Were Reaped!

User Benefits

Startup time relies heavily on the size of the code shipped by Trivago. Since the engineers rely heavily on and give back to open-source libraries such as Next.js, Preact, and react-use, they watch code size closely.

The new product reduced page weight from 2.1 MB to 1.7 MB (19%) for theme pages and from 4.1 MB to 2.6 MB (37%) for result pages. Turning the single-page application into multiple pages and using the automatic code-splitting feature by Next.js turned out to be very beneficial.

As a result, Trivago now runs more smoothly on weaker hardware. Android 6, which makes up about 0.5% of all Android clients is the weakest hardware that uses the Trivago application. Their testing shows the application works fluently on Android 6.

Developer Benefits

This is a solid tie back to why the rewrite started in the first place. Cleaner code base with quality, widely available documentation both internal and in terms of a global ecosystem available for searching on google and Stack Overflow. New developers have an easier time on-boarding and there is more of a sense of familiarity and transferrable skills to develop.

👁 The old versus new platforms

There is no definitive proof of faster development, the monthly merged pull requests are higher in the new codebase (see chart above) with the same number of engineers as there were working on the older cold base.

There are now ten releases per day as compared to the previous two. With a little more cleanup, the additional legacy systems will be turned off thus allowing more resources available for the new application.

Overall there is a cost to this big rewrite and there were quite a few struggles, revenue was lost though it paired well with the travel slow down of 2020. The engineering team grew immensely in terms of engineering skills as well as soft skills.

With all the setbacks considered, the project was definitely a success.

TRENDING STORIES
Jessica Wachtel is a developer marketing writer at InfluxData where she creates content that helps make the world of time series data more understandable and accessible. Jessica has a background in software development and technical journalism.
Read more from Jessica Wachtel
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.