---
title: Starting and Stopping Sync
slug: v4-8/sync/start-and-stop-sync
docTags: 
createdAt: 2023-08-22T20:57:32.293Z
---

Required only once, initiating the sync process automatically connects you with the mesh network. Once connected, you immediately begin receiving updates from set sync subscriptions and sending updates to subscribing remote peers.

## Starting Sync

To initiate the sync process:

:::CodeblockTabs
```swift
try! ditto.startSync()
```

```kotlin
try {
    ditto.startSync()
} catch (e: DittoError) {
    // handle error
}
```

```javascript
try {
  ditto.startSync()
} catch (err) {
  // handle error
}
```

```java
try {
    ditto.startSync();
} catch(DittoError e) {
    // handle error
}
```

```csharp
try
{
    ditto.StartSync();
}
catch (DittoException ex)
{
    // handle exception
}
```

```cpp
try {
  ditto.start_sync();
} catch (const DittoError &err) {
  std::cerr << err.what();
}
```

```rust
ditto.try_start_sync()?;
```

```dart
try {
  await ditto.startSync();
} catch (e) {
  // handle exception
}
```
:::

:::hint{type="info"}
Ensure the sync process remains active throughout your app's lifecycle by starting the sync process (`startSync`) in the top-most scope of your code.&#x20;
:::

## Stopping Sync

To stop the sync process, call the `stopSync` function. Once called, you will be disconnect from any peers and all active sync subscriptions will be paused.

:::CodeblockTabs
```swift
try! ditto.stopSync()
```

```kotlin
try {
    ditto.stopSync()
} catch (e: DittoError) {
    // handle error
}
```

```javascript
try {
  ditto.stopSync()
} catch (err) {
  // handle error
}
```

```java
try {
    ditto.stopSync();
} catch(DittoError e) {
    // handle error
}
```

```csharp
try
{
    ditto.StopSync();
}
catch (DittoException ex)
{
    // handle exception
}
```

```cpp
try {
  ditto.stop_sync();
} catch (const DittoError &err) {
  std::cerr << err.what();
}
```

```rust
ditto.try_stop_sync()?;
```

```dart
ditto.stopSync();
```
:::

