Home/Knowledge Hub/Client extensions & integration
Client extensions & integration
Liferay 7.4 Client Extensions: Reference Notes
What they are, why they exist and how the extension types fit together
Liferay 7.4 Client Extensions
Basic Concepts
Q1What is a Client Extension in Liferay 7.4?
A Client Extension is a mechanism for extending or integrating with Liferay while keeping much of the custom implementation outside the traditional Liferay OSGi runtime. Instead of modifying Liferay internals or deploying all customization logic as OSGi bundles, Client Extensions allow developers to connect external applications, frontend resources, services, OAuth clients, and other capabilities to Liferay through supported extension points. Conceptually:
This makes Client Extensions attractive for:
- External microservices
- React applications
- JavaScript/CSS customization
- Remote applications
- OAuth integrations
- External notification systems
- Custom element applications
- Headless architectures
Q2Why were Client Extensions introduced?
Traditional Liferay customization frequently relies on OSGi modules deployed directly into the Liferay runtime. This provides significant power but also creates tighter coupling:
The main architectural goals include:
- Better separation of concerns
- Easier platform upgrades
- Reduced dependence on Liferay internals
- Cloud-friendly deployment
- Independent development lifecycles
- Independent technology stacks
Q3What is the main difference between Client Extensions and OSGi modules?
An OSGi module executes inside the Liferay application runtime. A Client Extension generally integrates through supported external extension mechanisms rather than embedding all application logic inside that runtime.
Q4What are common Client Extension types?
Liferay 7.4 supports several Client Extension categories, depending on the product update and deployment environment. Important categories include:
- Custom Element
- Global CSS
- Global JavaScript
- OAuth 2 Application
- Object Action
- Object Validation
- Notification Type
- Theme CSS
- Theme Favicon
- Theme JavaScript
- Theme Spritemap
Some Client Extension types are especially relevant to Liferay’s cloud and SaaS-oriented architecture.
Client Extension Project Structure
Q5What does a Client Extension project look like?
A Client Extension project commonly contains configuration describing the extension together with the resources or source code required by that extension. A simplified structure might look like:
client-extensions/
|
+-- employee-dashboard/
|
+-- client-extension.yaml
+-- package.json
+-- src/
| +-- index.js
|
+-- assets/The most important configuration file is typically:
client-extension.yamlIt describes how Liferay should recognize and configure the extension.
Q6What is client-extension.yaml?
The client-extension.yaml file is the primary descriptor used to define Client Extensions. A simplified conceptual example is:
employee-dashboard:
type: customElement
name: Employee Dashboard
htmlElementName: employee-dashboard
urls:
- index.jsThe exact supported properties depend on the Client Extension type and the installed Liferay version. Therefore:
client-extension.yaml = Client Extension DescriptorIntermediate Concepts
Q7What is a Custom Element Client Extension?
A Custom Element Client Extension allows a frontend application to be exposed inside Liferay as a browser custom element. For example:
<employee-dashboard></employee-dashboard>The implementation could be created using technologies such as:
- React
- JavaScript
- TypeScript
- Other frontend frameworks
Conceptually:
This allows the frontend application to evolve with less coupling to Liferay’s Java/OSGi implementation.
Q8What is a Global CSS Client Extension?
A Global CSS Client Extension loads custom CSS resources into configured Liferay contexts. It can be useful for:
- Branding
- Corporate styling
- Common visual customization
- Portal-wide CSS adjustments
For example:
.portal-header {
font-weight: 600;
}
.company-banner {
border-radius: 8px;
}Instead of modifying Liferay’s internal theme source directly, the custom CSS can be managed as an extension.
Q9What is a Global JavaScript Client Extension?
A Global JavaScript Client Extension allows custom JavaScript resources to be introduced into selected Liferay contexts. Typical use cases include:
- Analytics integration
- Client-side event handling
- Third-party scripts
- Common browser-side behavior
However, global JavaScript should be used carefully because code executed globally can affect multiple pages.
Q10What is an OAuth 2 Client Extension?
OAuth 2 Client Extensions are particularly important when an external application needs secure access to Liferay APIs. Instead of embedding credentials directly into application code, OAuth 2 can be used to establish controlled API access. Conceptually:
For example, a Spring Boot microservice may authenticate and then call:
GET /o/headless-delivery/v1.0/sites/{siteId}/blog-postingsor a custom Object API such as:
GET /o/c/employeesClient Extensions and Headless APIs
Q11How do Client Extensions fit into a Headless Liferay architecture?
Client Extensions work naturally with Liferay’s Headless APIs. A modern architecture might look like:
The frontend does not need direct access to Liferay’s internal Java services. Instead, it communicates through supported APIs.
Q12Can a Client Extension call Liferay Objects?
Yes. This is an important architectural combination. Suppose we have an Employee Object. The generated API could expose an endpoint similar to:
GET /o/c/employeesA React-based Client Extension could retrieve the entries:
fetch(’/o/c/employees’)
.then(response => response.json())
.then(data => {
console.log(data.items);
});Conceptually:
Advanced Concepts
Q13Can a Client Extension communicate with an external microservice?
Yes. One of the major advantages of the Client Extension architecture is the ability to integrate Liferay with independently deployed services. For example:
The backend does not necessarily need to be implemented using Java. Possible technologies include:
- Spring Boot
- FastAPI
- Node.js
- .NET
- Go
- Serverless functions
Q14How is security handled?
Security depends on the Client Extension and integration architecture. Important mechanisms can include:
- OAuth 2
- Liferay permissions
- API authorization
- HTTPS
- CORS configuration
- Secure credential management
- External service authentication
A common machine-to-machine pattern is:
The key principle is:
Sensitive credentials should be handled by trusted backend services.
Q15Can Client Extensions use Liferay permissions?
Yes, when the extension accesses Liferay resources through Liferay’s APIs, the API operation remains subject to the applicable authentication and permission checks. For example:
A frontend Client Extension should therefore not be considered a security boundary. Hiding a button does not remove the user’s backend permission.
Q16What are Object Action Client Extensions?
Client Extensions can be combined with Liferay Objects to execute external business logic. Consider:
This approach helps keep sophisticated integration logic outside the Liferay runtime.
Q17What is an Object Validation Client Extension?
An Object Validation Client Extension can support externally implemented validation behavior for Object entries where the corresponding Client Extension mechanism is available. For example, consider:
The validation service could check:
- Department budget
- Vendor status
- Spending policy
Conceptually:
This is valuable when validation is too sophisticated to represent using simple configuration.
Client Extensions vs OSGi Modules
Q18When should Client Extensions be used instead of OSGi?
| Feature | Client Extension | OSGi Module |
|---|---|---|
| Execution | Often external/browser-based | Inside Liferay JVM |
| Coupling | Generally lower | Can be tightly coupled to Liferay Java APIs |
| Technology | React, JS, Spring Boot, FastAPI, etc. | Primarily Java/OSGi |
| Deployment | Extension-oriented deployment model | OSGi bundle deployment |
| Internal Ser- | Normally uses APIs/integration con- | Can directly use Liferay Java services |
| vices | tracts | |
| Upgrade Isolation | Generally stronger | Depends on APIs used by custom code |
| Microservices | Natural fit | Not its primary purpose |
| Deep Platform | Limited compared with OSGi | Strong |
| Logic |
A useful rule is:
whereas:
Client Extensions vs Objects
Q19What is the difference between Liferay Objects and Client Extensions?
They solve different problems and are frequently used together.
| Objects | Client Extensions | |
|---|---|---|
| Primary Purpose | Business data modeling | Platform extension/integration |
| Database Entity | Yes | Not inherently |
| CRUD | Generated | Implemented or consumed as required |
| REST API | Generated for custom objects | Can consume or integrate with APIs |
| Frontend | Generated/admin interfaces | Custom UI possible |
| External Logic | Can trigger/integrate with it | Strong integration mechanism |
Therefore, a powerful pattern is:
Real-World Example: Employee Portal
Q20How would you build an Employee Portal using Client Extensions?
Suppose the requirement is:
Create an Employee Portal where employees can view their profile, submit leave requests and see their leave history.
Step 1: Create Liferay Objects
Create:
Employee
LeaveRequestEmployee fields:
employeeId
firstName
lastName
email
department
designationLeave Request fields:
startDate
endDate
leaveType
reason
statusStep 2: Create the Relationship
One employee may have many leave requests:
Employee −−→ LeaveRequest
Step 3: Use Generated APIs
The published Objects expose APIs conceptually similar to:
GET /o/c/employees
GET /o/c/leaverequests
POST /o/c/leaverequestsStep 4: Create a React Client Extension
Create:
employee-dashboardThe UI might contain:
Employee Dashboard |
|---|
+----------------------------------+ |
| Welcome, Employee | |
+----------------------------------+ |
| Profile | |
| Leave Balance | |
| Apply for Leave | |
| Leave History | |
+----------------------------------+ |
+----------------------------------+Step 5: Connect React to Objects
Conceptually:
Example:
fetch(’/o/c/leaverequests’)
.then(response => response.json())
.then(data => {
console.log(data.items);
});Step 6: Add Workflow
A Leave Request can follow:
Step 7: Add External Integration
Suppose approved leave must also reach an HR system. The architecture could become:
Modern Liferay Architecture
A modern Liferay application can therefore combine:
This architecture separates:
- Presentation
- Business data
- Workflow
- Security
- Integration
- External business logic
Common Interview Questions
Q21Does a Client Extension run inside the Liferay JVM?
Not necessarily. A major purpose of Client Extensions is to allow functionality to be implemented without placing all custom code inside the Liferay JVM.
Q22Can Client Extensions replace all OSGi modules?
No. Client Extensions are excellent for external integrations, frontend customizations and loosely coupled architectures. OSGi remains appropriate when deep access to Liferay’s Java services, runtime behavior, or internal extension points is required.
Q23Can Client Extensions use React?
Yes. Custom Element Client Extensions are commonly used to integrate modern frontend applications with Liferay.
Q24Can Client Extensions call external APIs?
Yes, provided that authentication, authorization, networking and CORS requirements are correctly configured.
Q25Can a Spring Boot application act as part of a Client Extension architecture?
Yes. A common pattern is:
with communication through HTTP APIs and OAuth 2.
Q26Can FastAPI be used?
Yes. The external service does not have to use Java. For example:
This architecture is particularly useful for AI, machine learning, scientific computing and specialized Python workloads.
Architectural Decision Guide
Interview Takeaway
Prefer to read offline? Download the PDF edition (13 pages).
