A newer version of this documentation is available.

View Latest

Data Sync Locally on Device

    March 30, 2025
    + 12

    Description — Couchbase Lite Database Sync - Synchronize changes between databases on the same device

    Description — Couchbase Lite Database Sync - Synchronize changes between databases on the same device
    Related Content — Remote Sync Gateway | Peer-to-Peer Sync

    Overview

    Couchbase Lite supports replication between two local databases at the database, scope, or collection level. This allows a Couchbase Lite replicator to store data on secondary storage. It is useful in scenarios when a user’s device is damaged and its data is moved to a different device.

    Example 1. Replication between Local Databases
    CBLEndpoint* target = CBLEndpoint_CreateWithLocalDB(database2);
    
    replConfig.database = database1;
    replConfig.endpoint = target;
    
    CBLReplicator* replicator = CBLReplicator_Create(&replConfig, &err);
    CBLEndpoint_Free(target);
    
    CBLReplicator_Start(replicator, false);