Loading...

Modern enterprise apps demand real-time responsiveness, but traditional Salesforce development often slows you down with Apex, SOQL, and frequent deployments. Enter Change Data Capture (CDC), a powerful Salesforce feature that streams real-time changes (create, update, delete, undelete) directly into your Lightning Web Components (LWC), using the Emp API and without writing a single SOQL query.

Think of CDC as PushTopic 2.0, no query definitions, no polling, and no backend logic required. You subscribe to a change stream like /data/OpportunityChangeEvent, and boom: your UI reacts in real time to record changes made anywhere in Salesforce (or via API).

In this blog, you’ll learn how to use CDC with LWC to build a live-updating progress bar based on the Opportunity StageName field. This component updates automatically when the record changes, and vice versa, making it ideal for dynamic sales pipelines, dashboards, or workflow visualisations.

What is CDC in LWC?

Change Data Capture (CDC) is a Salesforce feature that allows you to receive real-time updates of data changes (create, update, delete, undelete) for Salesforce records. In  Lightning Web Components LWC, CDC is typically used with platform events and the Emp API (Streaming API) to subscribe to changes and update the UI automatically when data changes.

It’s a new version of Push Topic i.e no use of SOQL. In CDC you don’t need a SOQL query to generate a notification.

Use of CDC

  • Real-time Data Synchronization: Keeps data in sync between systems (e.g., syncing operational databases with analytics platforms).
  • Data Warehousing and ETL Optimization: Reduces load on source systems by only processing changed data, making ETL more efficient.
  • Auditing and Compliance: Tracks data changes over time, helping with regulatory audits and data lineage tracking.
  • Event-Driven Architecture: Triggers workflows or business logic based on data changes.
  • Backup and Recovery: Facilitates incremental backups by capturing only what has changed since the last backup.
  • Receive notifications: Get Salesforce record changes, including create, update, delete, and undelete operations.

How to Enable CDC

Go to setup, Search ‘Change Data Capture’ in Quick find box, click on change data capture and then select your required object and save.

I choose Opportunity for my requirement.

01 2

Sample JSON Response for update case:

This sample JSON contains information about all changes made to a particular object in the update case.

In the JSON below, we have updated the CloseDate, ExpectedRevenue, StageName, Probability, and Type.

Sample JSON Of Create Case:

In this blog, we will see how CDC can be used in LWC in Update case.

Now, let’s create a custom LWC component to update custom progress bar values on the basis of ‘Stage’ Update and if the value is updated from the progress bar, then it will also reflect on the record field ‘Stage’.

Html.

Css.

JS.

Apex class :

  1. handleSubscribe(): Subscribes to a CDC event channel (e.g., /data/OpportunityChangeEvent) so your component can receive real-time updates when a record changes (created, updated, deleted, etc.).

-1 means “start listening from new events only”, not from older stored events.

  1. handleUnsubscribe(): Stops the component from listening to CDC events by removing the subscription.
  • Calls unsubscribe() to stop receiving events by removing the subscription.
  • Useful for cleanup when the component is destroyed or navigated away from.
  1. registerErrorListener(): Registers a global error handler for any issues that occur while receiving events via the EMP API.

Sets up a callback via onError() to log or handle errors from the subscription system (e.g., network issues, auth errors, invalid channel, etc.)

Watch the Demo Video

Conclusion

By integrating Salesforce CDC directly into your Lightning Web Components, you’re stepping into a future-proof, event-driven architecture where the UI stays in sync with backend data in real time without polling, SOQL, or Apex callouts.

This approach minimizes server load, improves UX, and dramatically reduces Apex dependency. Whether you’re building responsive UIs, dashboards, or real-time workflows, CDC + LWC is the fastest, cleanest, and most scalable path forward.

If you’re still using PushTopics or Apex-triggered updates, it’s time to evolve. CDC is the new real-time standard.

Frequently Asked Questions
What is Salesforce Change Data Capture (CDC)?
Salesforce CDC is a real-time event-based feature that lets you track changes (insert, update, delete, undelete) in Salesforce records and stream them to clients or external systems.
How does CDC improve performance compared to using SOQL polling in LWC?
To streamline your workflows, CDC eliminates the need for frequent SOQL queries by pushing real-time data updates to the client. This reduces server load and improves UI responsiveness without consuming governor limits unnecessarily.
Can I use CDC in LWC without Apex?
Yes, you can connect LWC directly to a CDC event channel using the EmpApi module, which lets the component subscribe to platform event streams without the need for Apex triggers or polling.
What is the difference between CDC and Platform Events in Salesforce?
While both are part of Salesforce's event-driven architecture, CDC is specifically designed to publish record-level changes automatically, whereas Platform Events are custom events you define and publish manually for app communication.
Can CDC be used with custom objects in Salesforce?
Yes. CDC supports both standard and custom objects. You just need to enable Change Data Capture for your custom object in Setup, and Salesforce will generate a corresponding CustomObjectNameChangeEvent channel.

No Data Found.

Related Articles
How to Integrate NikoHealth to Salesforce

Healthcare organizations using NikoHealth often need patient, insurance, order, invoice, and prescription data available inside Salesforce. As data grows, manually updating records across systems becomes difficult and can lead to delays, duplicate work, and data inconsistencies. NikoHealth to Salesforce integration helps solve this challenge by automatically synchronizing data between both platforms. Instead of building custom […]

Read More
Orchestrator vs. Traditional Flows

Businesses use Salesforce automation to reduce manual work, improve efficiency, and automate repetitive business processes. Two commonly used automation approaches inside Salesforce are Traditional Flows and Flow Orchestrator. Traditional Flows are mainly used for simple automation tasks such as updating records, sending notifications, creating tasks, and automating business logic. Flow Orchestrator is designed for more […]

Read More
The Rise of Agentic Government_ What Salesforce’s 2026 Insights Mean for the Future of Public Sector AI

Government technology has often been seen as slower to evolve than the private sector. But Salesforce’s latest research challenges that idea in a big way. In fact, the new findings suggest that public sector organizations may now be moving faster than many businesses when it comes to adopting AI agents and preparing for a more […]

Read More
How To Use Email Service in APEX

Managing approvals, updates, and record changes directly from email can significantly improve efficiency within Salesforce workflows. Instead of logging in, navigating records, and manually updating fields, users can simply respond to emails and trigger automated updates using Email Service in APEX. This approach is especially useful for businesses leveraging Salesforce automation and looking to enhance […]

Read More
Design and Implementation of Salesforce Jira Task Integration 1 1

Businesses have been using Salesforce for CRM operations and Jira for Agile project tracking. However, without integration, teams manually update both systems, leading to data inconsistency and inefficiency.This mechanism establishes a real-time integration between Salesforce and Jira, allowing seamless synchronization of tasks and agile board statuses.  A custom Salesforce dashboard was developed that replicates Jira-style […]

Read More
Dark Mode in Salesforce Enabling It and Creating Theme Ready Lightning Web Components with SLDS 2.0 1 1

With the Winter ’26 release, Salesforce introduced Dark Mode in Lightning Experience. Dark Mode has been introduced as a beta feature in Winter ’26, and at first it was available only for Starter Edition orgs. It is now rolling out further with Spring ’26 to Professional, Enterprise, and Developer editions. To use Dark Mode, Salesforce […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818