Best practice - CB Sync Gateway


Currently our application is 100% offline first, where the application installed in the user’s machine talks to CB Server via CB Lite and Sync Gateway.

App (local) > CB Lite (local) > CB Sync Gateway (cloud) > CB Server (cloud)

It works fine. Now we’re planning to deploy our application to the cloud also so that the group of users who’re always online can connect to the cloud via a web browser. We’re planning to connect the application deployed in the cloud directly to CB Server.

App (cloud) > CB Server (cloud)

Is this a good approach? Or should we connect the application deployed in the cloud to the CB Sync Gateway - REST apis?

App (cloud) > CB Sync Gateway (cloud) > CB Server (cloud)

Our main concern is that if we interact directly with CB Server, will those changes be captured by Sync Gateway to be synced down to CB Lite running in offline user’s machines… Please advise…


Yes. The docs will be imported to SG so long as you have it configured to do so. Not in front of an example right now, but I can get you the config if you need it.


Thanks for the reply, Hod. Please share the configuration.


Hi Dony,

Here’s a simple example. The last two lines are the important ones.

  "log": ["*"],
  "databases": {
    "inventory": {
      "server": "http://localhost:8091",
      "bucket": "inventory",
      "username": "Administrator",
      "password": "Password",
      "users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } },
      "allow_conflicts": false,
      "revs_limit": 20,
      "enable_shared_bucket_access": true,
      "import_docs": "continuous"


Not sure what version of platform you are on. Assuming you are on Sync Gateway 1.5 and above, you can leverage shared bucket access as described in our docs. This will enable changes from CBS to be synced over to CBL.

This blog may also help