A newer version of this documentation is available.

View Latest

Data Sync Locally on Device

    March 23, 2025
    + 12

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

    Overview

    Couchbase Lite supports replication between two local databases. This allows a Couchbase Lite replicator to store data on secondary storage. It is especially useful in scenarios where a user’s device may be damaged and its data moved to a different device.

    Example 1. Replication between Local Databases
    var targetDatabase = new DatabaseEndpoint(database2);
    var config = new ReplicatorConfiguration(db, targetDatabase)
    {
        ReplicatorType = ReplicatorType.Push
    };
    
    var replicator = new Replicator(config);
    replicator.Start();

    Note: The code does not compile in Couchbase Lite Community Edition.