Introduction
Traditionally, developers have used OSGi modules to customize Liferay. These modules are very powerful and allow you to modify or extend almost any feature of the platform. OSGi can be quite complicated to learn and is well integrated with Liferay’s core system, which means that understanding the system well and experience with Java-based development are necessary.
Liferay offered Client Extensions to streamline the process. They run outside the platform and connect via APIs. Client Extensions are more lightweight and flexible, easier to build, deploy, and maintain, especially for modern frameworks and languages besides Java.
To help you choose the optimal strategy for your upcoming Liferay project, we will examine and compare Client Extensions and OSGi in greater detail in this post.
Prerequisites
Liferay DXP/Portal 7.4+
Basic understanding of Liferay Objects, Client Extensions, and OSGi modules
Familiarity with modular application development and APIs
Environment Requirements
Java
Liferay
OSGi (Open Service Gateway Initiative)
OSGi is used to structure new Java applications in modules. Within Liferay, an OSGi module (or a bundle) is a module that is executed in a self-contained manner in the Liferay container. These modules are designed to integrate with the core Liferay services and APIs. OSGi offers a dynamic component architecture that can install, start, stop, and update bundles without having to restart the server, as OSGi allows.
Key characteristics of OSGi modules include :
Java-centric : Development is based on Java and requires strong Java knowledge.
In-container deployment : They run within the same Java Virtual Machine (JVM) as Liferay itself.
Deep integration : They are best for tasks that need direct access to Liferay’s core features, like building custom services or changing how built-in functions work.
What are Liferay Client Extensions?
The newest method for advancing Lifray Client Extensions is much more convenient than the former OSGi modules that consisted of complicated blocks of code contained within the Liferay DXP. Client Extensions reside outside of the Liferay DXP container and only communicate with the platform using the provided headless APIs. It is this neat architecture that sets Client Extensions apart.
Key characteristics of Client Extensions include :
Technology agnostic : Any developer with appropriate experience in JavaScript frameworks, like React or Angular, or in backend frameworks, like Spring Boot.
Decoupled architecture : Since the extensions are running outside of the core Liferay system, they do not consume resources from the Liferay process, which enhances application performance. In addition, an application with a buggy extension will not bring the entire server down, or slow it down at least.
Reduced deployment complexity : You can easily deploy Client Extensions on any setup—whether it’s Self-Hosted, Liferay PaaS, or Liferay SaaS.
Client Extensions vs OSGi: A Comparison
1. Architecture
OSGi : Runs inside the Liferay JVM as part of the OSGi container. All modules are tightly coupled with the platform.
Client Extensions : Run outside of the Liferay JVM (in separate services or containers). They interact with Liferay through APIs and configuration.
2. Development Effort
OSGi : Requires deeper knowledge of the OSGi framework, service components, and Liferay internal APIs. Development is powerful but more complex.
Client Extensions : Much simpler. Developers create YAML configurations or standalone apps (React, Node.js, Spring Boot, etc.) without dealing with OSGi internals.
3. Deployment
OSGi : Modules are deployed directly into the Liferay runtime (bundled JARs). A faulty module can impact the whole server.
Client Extensions : Deployed as an independent service, application, or Docker container outside of the Liferay runtime. Because they are decoupled from the core, you would not affect the server’s operation if you have a client extension issue.
4. Scalability & Cloud Readiness
OSGi : Since OSGi modules run inside the Liferay server, the only way to scale them is by scaling the whole Liferay server itself.
Client Extensions : Much more cloud-friendly. Each extension runs separately, so you can scale it up or down on its own, just like a microservice.
5. Maintenance
OSGi : Harder to maintain, especially during upgrades. Changes in Liferay APIs often require rework.
Client Extensions : Easier upgrades since they depend mostly on stable headless APIs and not internal Liferay services.
6. Use Cases
OSGi is best for :
Deep platform customizations (hooks into core features).
Complex service builder modules.
Scenarios where direct access to Liferay internals is required.
Client Extensions are best for :
External integrations (microservices, REST APIs).
Frontend customizations (React, Angular, JS widgets)
Lightweight extensions that need to run independently of the portal.
Conclusion
Both OSGi and Client Extensions are powerful, but they solve different problems. OSGi is the right choice when you need deep customizations within Liferay itself. Client Extensions are the better choice for cloud-friendly, lightweight, and decoupled solutions. For most modern projects, Liferay recommends starting with Client Extensions, as they simplify development and future-proof your architecture.